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; }
标签:060,color,margin,li,ul,nav,height,border,CSS 来源: https://www.cnblogs.com/yuer20180726/p/11005571.html