码迷,mamicode.com
首页 > 其他好文 > 详细

flex图片布局

时间:2017-02-24 17:56:55      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:tle   lex   高度   block   lock   ati   doctype   over   har   

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>flex图片布局</title>
<style>
body {
margin: 0;
padding: 0;
}

.box {
float: left;
width: 30%;
margin-top: 10px;
margin-left: 2.5%;
height: 0;
padding-bottom: 33.98%;
background-color: #dbe0e4;
background:red;
background-size: cover;
display:block;position: relative;


}
img{

background: red;
margin: 0 auto;
max-width: 100%;
/*超出宽度的图片限制最大显示宽度
max-height:250px;
/*超出高度的图片限制最大显示高度*/
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
</style>
</head>

<body>
<div class="box">
<img src="" >
</div>
<div class="box">
<img src="" >
</div>
<div class="box">
<img src="" >
</div>
<div class="box">
<img src="" >
</div>
<div class="box">
<img src="" >
</div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</body>

</html>

flex图片布局

标签:tle   lex   高度   block   lock   ati   doctype   over   har   

原文地址:http://www.cnblogs.com/luckyuns/p/6439571.html

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