編輯本博客css
font-size: 20px;
font-weight: bolder;
font-family: "Microsoft YaHei UI","微軟雅黑","Arial",sans-serif;
text-align: center;
清除a標籤樣式html
text-decoration: none;
行高設置和盒子同樣的高度文本將垂直居中顯示web
line-height: 150px;
仿造a標籤,鼠標移動上去顯示小手狀態ide
cursor: pointer;
將line-height:盒子高度;post
經過對父級元素設置padding屬性來控制字體
padding-top=(盒子高度-(行高+字體大小)*行數)/2網站
備選字體能夠用逗號分隔設置多個spa
font-size: 15px; line-height: 20px; font-family: "宋體"; /*上面三行等價於下面一行*/ font: 15px/20px "宋體";
設置首行文字縮進,單位一般用em單位,1em等於一個字體大小。3d
text-indent: 2em;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>超連接美化</title> <style type="text/css"> *{ padding: 0; margin: 0; } .bar{ width: 960px; overflow: hidden;/*也能夠經過僞元素after來設置*/ background-color: #666666; margin: 0 auto; /*設置邊框圓角*/ -webkit-border-radius: 3px 3px 0px 0px; -moz-border-radius: 3px 3px 0px 0px; border-radius: 3px 3px 0px 0px; } /*.bar:after{*/ /*content: "";*/ /*display: block;*/ /*clear: both;*/ /*}*/ ul li{ list-style: none; } .bar ul li{ float: left; width: 160px; height: 40px; line-height: 40px; text-align: center; color: white; font-family: "幼圓"; } /*a標籤不繼承父元素的color屬性*/ .bar ul li a{ display: block;/*行內元素,必須設置成block後設置寬高*/ color: white; text-decoration: none; width: 160px; height: 40px; } .bar ul li a:hover{ background-color: #A9A9A9; } </style> </head> <body> <div class="bar"> <ul> <li><a href="#">網站導航</a></li> <li><a href="#">網站導航</a></li> <li><a href="#">網站導航</a></li> <li><a href="#">網站導航</a></li> <li><a href="#">網站導航</a></li> <li><a href="#">網站導航</a></li> </ul> </div> </body> </html>