首页 > 代码库 > 用css编写自适应九宫格
用css编写自适应九宫格
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.video_list{
list-style-type: none;
}
.video_list li{
width: 32%;
float: left;
padding-bottom: 32%;
position: relative;
text-align: center;
font-size:35px;
margin-left: 1%;
margin-bottom: 1%;
}
.video_list div{
position: absolute;
background-color:#09BE07;
border:1px solid #ccc;
width: 100%;
height: 100%;
}
.video_list span{
display: inline-block;
margin-top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
</style>
</head>
<body>
<ul class="video_list">
<li><div><span>1</span></div></li>
<li><div><span>2</span></div></li>
<li><div><span>3</span></div></li>
<li><div><span>4</span></div></li>
<li><div><span>5</span></div></li>
<li><div><span>6</span></div></li>
<li><div><span>7</span></div></li>
<li><div><span>8</span></div></li>
<li><div><span>9</span></div></li>
</ul>
</body>
</html>
用css编写自适应九宫格