好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

css实现文字图片垂直居中效果


复制代码

代码如下:


<!docty PE ht ML >
<html>
<head>
< ;m eta charset="utf-8">
<t IT le>轻松实现:垂直居中文字图片</title>
<!-- START Plu gin CSS -->
<style type="text/css">
html{
font- Size: 12px;
}
.control{
width:600px;
border:1px solid # 000;
padding:10px;
m arg in:0 auto;
}
.m ai n_header{
border:1px solid blue;
h ei ght:100px
}
.main_body{
border:1px solid red ;
height:500px
}
.main_footer{
border:1px solid #ccc;
height:100px
}
.main_header,.main_body,.main_footer{
margin-bottom:5px;
}
.content{
width:102px;
margin:10px auto;
overflow:hidden;
}
.content .info{
width:100px;
height:200px;
border:1px solid green;
dis play :table-cell;
vert ical -align:middle;
margin:0 auto;
}
.content .fix{
display:inline;
width:0;
height:100%;
vertical-align:middle;
zoom:1; /*触发IE hasLayout*/
}
.content .desc{
display:inline;
width:100%;
vertical-align:middle;
zoom:1; /*触发IE hasLayout*/
}
.content . img {
float:left;
width:100px;
height:100px;
border:1px solid #333;
line-height:100px;
text-align: center ;
*font -s ize:100px; /* IE */
}
.content img{
vertical-align:middle;
}
</style>
<!-- END Plugin CSS -->
</head>
<body>
<div class="control js_control">
<!-- START header -->
<div class="main_header" >
header
</div>
<!-- END header -->
<!-- START body -->
<div class="main_body">
<div class="content">
<div class="info">
<div class="fix"></div>
<div class="desc">
无霜制冷,不仅节能省 电 ,还免去除霜烦恼。冷冻 速度快 ,食材由内到外均匀冻透,保鲜效果好,口感新鲜,更能锁住营养不流失。
</div>
</div>
</div>
<div class="content">
<div class="img">
<img src="P020140403556494729753. jpg " width="50" height="50" />
</div>
</div>
</div>
<!-- END body -->
<!-- START footer -->
<div class="main_footer">
footer
</div>
<!-- END footer -->
</div>
<!-- START Plugin JS -->
<script type="text/javascript">
</script>
<!-- END Plugin JS -->
</body>
</html>

总结

以上是 为你收集整理的 css实现文字图片垂直居中效果 全部内容,希望文章能够帮你解决 css实现文字图片垂直居中效果 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于css实现文字图片垂直居中效果的详细内容...

  阅读:21次