CSS + ul li 横向排列的两种方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

<title>CSS + ul li 横向排列的两种方法 </title>

</head>

<body>

  <div id="nav">

  <ul>

    <li><a href="http://blog.csdn.net/superbirds" title="">superbirds</a></li>

    <li><a href="http://blog.csdn.net/superbirds" title="">superbirds</a></li>    

    <li><a href="http://blog.csdn.net/superbirds" title="">superbirds</a></li>

    <li><a href="http://blog.csdn.net/superbirds" title="">superbirds</a></li>

  </ul>

  </div>

</body>

</html>

CSS代码一:

* {

    margin: 0;

    border: 0;

    padding: 0;

    font-size: 13pt;

}

 

#nav {

    height: 40px;

    border-top: #060 2px solid;

    border-bottom: #060 2px solid;

    background-color: #690;

}

 

#nav ul {

    list-style: none;

    margin-left: 50px;

}

 

#nav li {

    display: inline;

    line-height: 40px;

    float:left

}

 

#nav a {

    color: #fff;

    text-decoration: none;

    padding: 20px 20px;

}

 

#nav a:hover {

    background-color: #060;

}

CSS代码二:

* {

    margin: 0;

    border: 0;

    padding: 0;

    font-size: 13pt;

}

 

#nav {

    height: 40px;

    border-top: #060 2px solid;

    margin-top: 100px;

    border-bottom: #060 2px solid;

    background-color: #690;

}

 

#nav ul {

    list-style: none;

    line-height: 40px;

    margin-left: 50px;

}

 

#nav li {

    display: block;

    float: left;

}

 

#nav a {

    display: block;

    color: #fff;

    text-decoration: none;

    padding: 0 20px;

}

 

#nav a:hover {

    background-color: #060;

}

  

  

posted @ 2019-06-11 19:38  爱笑的小宇宙  阅读(39075)  评论(0编辑  收藏  举报