码迷,mamicode.com
首页 > Web开发 > 详细

div+css:div中图片垂直居中

时间:2016-12-07 14:06:38      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:div   ica   utf-8   isp   text   cell   ext   com   nbsp   

div中图片垂直居中

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <title></title>
 6     <style>
 7     .box {
 8         width: 200px;
 9         height:200px;
10         display: table-cell; 
11         /* 水平居中 */
12         text-align:center; 
13          /* 垂直居中 */ 
14         vertical-align:middle;
15         border: 1px solid #f40;
16     }
17     </style>
18 </head>
19 <body>
20     <div class="box">
21     <img src="111.png"/>
22     </div>
23 </body>
24 </html>     

显示结果:

技术分享

 

div+css:div中图片垂直居中

标签:div   ica   utf-8   isp   text   cell   ext   com   nbsp   

原文地址:http://www.cnblogs.com/ooo0/p/6140729.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!