<style type="text/css">
<!--
.shoucang {
width: 58px;
height: 300px;
float: right;
background-color: #CCC;
border: 1px solid #999;
}
.shoucang .sc_ul {
width: 21px;
margin-right: auto;
margin-left: auto;
list-style-type: none;
padding-top: 20px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
}
.shoucang .sc_ul li {
height: 80px;
width: 21px;
margin-bottom: 9px;
color: #FFF;
text-decoration: none;
text-align: center;
vertical-align: middle;
background-color: #FF0000;
font-size: 12px;
border: 1px solid #666;
}
-->
</style>
</head>
<body>
<div class="shoucang">
<ul class="sc_ul"><li>设为首页</li><li>收藏本站</li>
<li class="no">联系方式</li>
</ul>
</div>
问题补充:不但要垂直居中,而且还要左右居中,IE和火狐都要能通过。。
需要准备的材料分别有:电脑、html编辑器、浏览器。
1、首先,打开html编辑器,新建一个html文件,例如:index.html,填充问题基础代码。
2、在index.html中的<style>标签中,将“.shoucang .sc_ul li”中的“height: 73px;”调整为:height: 73px;padding-top: 7px;。
3、最后,浏览器运行index.html页面,此时发现li标签中的文字被垂直和水平居中了。