编辑本博客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>