2017-12-22 4 views

Antwort

0

setiing Breite propery für li wird

ul {padding: 16px; 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: hidden; 
 
    background-color: #333333; 
 
} 
 

 
li { 
 
    float: left; 
 
    width:150px; 
 
} 
 
ul { display: inline-block; 
 
} 
 
li a { 
 
    display: block; 
 
    color: white; 
 
    text-align: center; 
 
    padding: 16px; 
 
    text-decoration: none; 
 
} 
 

 
li a:hover { 
 
    background-color: #111111; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
</head> 
 
<body> 
 
<div style="text-align:right"> 
 
<ul> 
 
    <li><a href="#home">Home</a></li> 
 
    <li><a href="#news">News</a></li> 
 
    <li><a href="#contact">Contact</a></li> 
 
    <li><a href="#about">About</a></li> 
 
</ul> 
 
</div> 
 
</body> 
 
</html>

tun
0

Sie können einen Rand zu jedem Link hinzufügen Raum zwischen ihnen zu schaffen. Wenn Sie das Navigationsgerät dehnen möchten, können Sie die Breite auf 100% einstellen.

li a { 
display: block; 
color: white; 
text-align: center; 
padding: 16px; 
text-decoration: none; 
margin-right: 20px; 
} 

ul { 
padding: 16px; 
list-style-type: none; 
margin: 0; 
padding: 0; 
overflow: hidden; 
background-color: #333333; 
width: 100%; 
} 
Verwandte Themen