CSS Ausrichten der Navigationsleiste mit Bildern und text
Ich habe ein Menü (siehe Bild unten), die ich versuche, korrekt auszurichten, den text mit den Bildern (also [img] [text]) sowie "Strecken" Sie den gesamten Inhalt passen alle die Breite.
Bild:
HTML:
<div id="menu">
<ul>
<li><a class="current" href="home.html" title="">HOME</a></li>
<li><a href="services.html" title="">TRANSPORT</a></li>
<li><a href="#" title="">ACCOMODATION</a></li>
<li><a href="#" title="">DEALS</a></li>
<li><a href="contact.html" title="">CONTACT</a></li>
</ul>
</div>
CSS:
#menu{
width:900px;
height: 50px;
clear:both;
background-color: #f7951e;
font-family: 'Exo 2', sans-serif;
text-align: center;
}
#menu ul{
font-family: 'Exo 2', sans-serif;
list-style:none;
margin-top: 5px;
margin-bottom: 5px;
display:block;
float: left;
width: auto;
}
#menu ul li{
font-family: 'Exo 2', sans-serif;
list-style:none;
display:inline;
width:auto;
height:50px;
line-height:42px;
font-size:18px;
}
#menu ul li a{
font-family: 'Exo 2', sans-serif;
font-size: 18px;
height: auto;
width: auto;
float:next;
text-decoration: none;
color:#fff;
padding-left: 40px;
padding-right: 10px;
}
#menu ul li a:hover{
height:auto;
width: auto;
text-decoration:none;
color: #fff;
}
#menu ul li a.current{
height:auto;
width: auto;
text-decoration:none;
color: #fff;
}
#menu ul li:nth-of-type(1){
background:url(./images/iconza/house_32x32.png) no-repeat;
float: start;
padding-top: 5px;
padding-bottom: 10px;
}
#menu ul li:nth-of-type(2){
background:url(./images/iconza/Car.png) no-repeat;
float: start;
padding-top: 5px;
padding-bottom: 10px;
}
#menu ul li:nth-of-type(3){
background:url(./images/iconza/house.png) no-repeat;
float: start;
padding-top: 5px;
padding-bottom: 10px;
}
#menu ul li:nth-of-type(4){
background:url(./images/iconza/offer.png) no-repeat;
float: start;
padding-top: 5px;
padding-bottom: 10px;
}
#menu ul li:nth-of-type(5){
background:url(./images/iconza/mail_32x32.png) no-repeat;
float: start;
padding-top: 5px;
padding-bottom: 10px;
}
- Ich bin mir ziemlich sicher, dass es bereits eine Antwort, um hier in stackoverflow.com/search?q=vertical+align+image+text 😉
InformationsquelleAutor Brian | 2014-01-13
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich würde vorschlagen, zu verwenden
display: table-cell;
im#menu ul li
stattfloat: left;
(ich habe gelernt, aus einem Buch über "responsive design"), und legen Sie hintergrund-Bilder in html-img:siehe meine LIVE-DEMO
Hier ist die geänderte html:
und css: