在IE8/FireFox下如何让div内的table垂直居中?[

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

<title></title>

</head>

<body>
<div style="width:500px;height:500px;background-color:Red;">
<table style="width:100px;height:100px;background-color:Blue;margin:0px auto;">
<tr>
<td>
</td>
</tr>
</table>
</div>
</body>

</html>
---------------------------------------

红色div里有个蓝色table,现在table可以水平居中.请问:
如何让table水平靠右或水平靠左?
如何让table垂直居中或居上或居下?

---------------------------------------

1.

table水平靠左
<table style="width:100px;height:100px;background-color:Blue;margin:0px auto;" align="left">
table水平靠右
<table style="width:100px;height:100px;background-color:Blue;margin:0px auto;" align="right">
----------------------------------------------------

2.

通过DIV控制TABLE--------》这里是正居中
<style type="text/css">
#Frame
{
width:500px;
height:300px;
background-color:#666666;
position:absolute;
left:50%;
top:50%;
margin-left:-250px;
margin-top:-150px;
}
</style>
................
<div id="Frame">
<table>
<table>
<div>

-----------------------------------------------

3.

都可以用margin来实现,关于水平靠左靠右可以用:margin:0px auto; align:left 或者 right;
或者在div里面给这个table定义:div { text-align:right 或者 left}

关于table整体垂直居中、靠上、向下,也可以用margin来完成,不过得根据div的高度和table的高度来决定。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值