如果没有行中的最后一项,我如何获得此结果:
margin-right: 30px;
在 CSS 中,现在我使用:
margin-right: 30px;
margin-bottom: 30px;
它应该像 ios 主屏幕
http://www4.picturepush.com/photo/a/12640862/img/12640862.png http://www3.picturepush.com/photo/a/12640866/img/12640866.png
html:
<div class="home-main">
<a href="t1home" class="item"><h1>Hallo</h1></a>
<a href="t1home" class="item"><h1>Hallo</h1></a>
<a href="t1home" class="item"><h1>Hallo</h1></a>
<a href="t1home" class="item"><h1>Hallo</h1></a>
</div>
CSS:
.home-main {
width: 90%;
max-width: 960px;
min-height: 100px;
margin: 0 auto;
overflow: hidden;
text-align: center;
}
.home-main a {
width: 126px;
min-height: 126px;
max-height: 166px;
margin-right: 30px;
margin-bottom: 30px;
background-color: #777;
float: left;
color: #fff;
text-decoration: none;
}
.home-main a:nth-last-child(1){
margin-right: 0;
}
.home-main a h1 {
width: 100%;
height: 33px;
margin: 0;
margin-top: 126px;
padding-top: 7px;
font-size: 19px;
text-align: center;
background-color: #222;
}
@media screen and (width:320px){
.home-main a:nth-child(even) {
margin-right: 0;
}
}