ul of the CSS navigation bar design of labels in a row li

HTML page element in the design,
the list has the same function with a Class li tag.
Such as menu navigation bar.



First, the original style - the display : List-Item ;




Second, the change line  -  the display : inline-Block ;





three final results





four code

<!DOCTYPE html>  
<html>  
<head>  
<style>  
    ul {  
        margin: 0;  
        padding: 0;  
        background-color: #444;  
    }  
    ul li {  
        display: inline-block;  
    }  
    li a {  
        display: block;  
        color: white;  
        text-align: center;  
        padding: 16px;  
        text-decoration: none;  
    }  
    li a:hover {  
        background-color: #888;  
    }  
</style>  
</head>  
<body>  
    <h2>Navigation Menu</h2>  
    <p>In this example, we use CSS to style the list horizontally, to create a navigation menu:</p>  
    <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>  
</body>  
</html>  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-

Guess you like

Origin www.cnblogs.com/eddyz/p/10972509.html