深圳网站建设、深圳建网站、网站建设公司定制属于您的高端个性化网站!

搜索深圳网站建设相关案例及相关信息 服务热线:13530005572/15112579390
首页 > 网站建设知识 > 5种实现垂直居中css

5种实现垂直居中css

  • 所属分类:网站建设知识
  • 作者: 利来w66(中国)有限公司
  • 更新时间: 2015-1-23 15:17:46
  • 返回列表
方法1 、line-height: 
<style>
.content {
   height:240px;
   line-height: 240px;
}
</style>
<div class="content">
       深圳网站建设-利来w66(中国)有限公司
</div> 




方法2 、:before: 
<style>
 .content {
     height: 240px;
 }
.child:before {
  content: ' ';
  display: block;
 height: 120px;
 }
</style>
<div class="content">
    <div class="child">
深圳网站建设-利来w66(中国)有限公司
   </div>
</div>

方法3 、padding-top:
<style>
.content {
  height:240px;
}
 .child {
  padding-top: 120px;
}
</style>
<div class="content">
     <div class="child">
        深圳网站建设-利来w66(中国)有限公司
     </div>  
</div> 

方法4、 position:absolute: 
<style>
.content {
 position:absolute;
 height:240px;
}
.child {
  position: relative;
  top:50%;
}
</style>
<div class="content">
   <div class="child">
       深圳网站建设-利来w66(中国)有限公司
  </div>  
</div> 

方法5、display:table-cell; 
<style>
#content {
  display:table;
}
 #child {
 display:table-cell;
 vertical-align:middle;
 height: 300px;
}
</style>
<div id="content">  
 <div id="child">  
       深圳网站建设-利来w66(中国)有限公司
 </div>  
</div>

相关推荐

您值得信任的网站建设专家!

为其提供系统的基于互联网的品牌行销策略 、 创意执行 、 追踪运营服务 。