您的位置:首页 > Web前端 > CSS

IE 8 下面的垂直水平居中

2016-02-03 00:00 375 查看
摘要: IE 8 下面的垂直水平居中

<style>
.box{ width:300px; height:300px; background:#ccc; text-align:center;}
.line{ display:inline-block; height:100%; width:0px; vertical-align: middle; }
.asas{ display:inline-block;}
</style>
</head>

<body>

<div class="box">
<div class="line"></div>
<span class="asas">sadsadasdas</span>
</div>

其实还有一种方法可以实现:<button></button> 标签中的内容自动居中,但是这样写的话需要修改样式,一般人也不会这样使用,因为这样不符合前端的代码设计思路。
ie6 下想要将内容居中
.building{width: 100%;height: 100%;text-align:center;}
<div class="building">
<img src="./images/building.gif" />
</div>

经过我的测试margin: 0,auto;是没用的注意
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IE 8 居中样式