居中css代码怎么写( 二 )


3. div居中代码怎么写 如果只是水平居中的话 , 只需要先定义DIV的宽度 , 再设置外边距margin属性的左右边距为auto即可 。此时DIV便会相对于它的父容器水平居中 。
比如 <div class=div_a><div class="div_b"><div></div>
设置div_b的样式
.div_b{width:100px; margin:0 auto;}
这样div_b便在div_a中水平居中了 。如果外面没有父DIV , 则div_b便相对于整个页面居中 。注意如果div_b定义了浮动属性float则无效 。
4. css代码如何实现居中 .corpmenu {
CLEAR: both; background-color:#32648f; WIDTH: auto; HEIGHT: 45px; RIGHT:auto;
text-align: center;
}
.corpmenu UL {
PADDING-RIGHT: auto; PADDING-LEFT: auto; PADDING-BOTTOM: 100px; MARGIN: 0px 0px 0px 0px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none;
text-align: center;
}
.corpmenu LI {
BACKGROUND: url(GSMenuRight.gif) no-repeat right 50%;
display: inline-block;
}你试试 , 我是按照
5. 这个网页居中CSS样式怎么写哦 <table border="1" width="729" id="table1" height="50" style="margin:0 auto;">
<tr><td rowspan="2" width="120" height="44">aaa</td>
<td width="263" height="25" colspan="3">ccc</td>
<td rowspan="2" width="121" height="44">ddd</td>
<td rowspan="2" width="121" height="44">yyyy</td>
</tr>
<tr>
<td width="121" height="25">111</td>
<td width="121" height="25">222</td>
<td width="121" height="25">333</td>
</tr>
</table>
也可以再外面套个DIV 设置下宽 , margin:0 auto;

居中css代码怎么写

文章插图