首页 > 其他 > 详细

使用display:table进行垂直居中

时间:2016-05-31 18:51:12      阅读:153      评论:0      收藏:0      [点我收藏+]

这个问题,属于常识性的吧,可以了解了解。demo如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>table-cell垂直居中</title>
<style type="text/css">
    *{margin:0;padding:0;border:0;}
    body,html{width:100%;height:100%;}
.ston_wrap{width:100%;height:100%;display: table;}
.ston_box{width:600px;margin:0 auto;height: 100%;}
.ston_content{display: table-cell;vertical-align: middle;background: #fcc;border:1px solid #fff;}

</style>

</head>
<body>
<div class="ston_box">
    <div class="ston_wrap">
        <div class="ston_content">
            <h1>内容1</h1>
            <h1>内容2</h1>
            <h1>内容3</h1>
            <h1>内容4</h1>
            <h1>内容5</h1>
            <h1>内容6</h1>
            <h1>内容7</h1>
            <h1>内容8</h1>
            <h1>内容9</h1>
            <h1>内容1</h1>
        </div>
    </div>
</div>
</body>
</html>

 

使用display:table进行垂直居中

原文:http://www.cnblogs.com/StruggleStudyhard/p/5546776.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!