我正在修复中。我有六个特色帖子(图片),我想以这样的方式出现——
http://media.prothug.com/2013/05/wpid-featt1.png
但我明白了
http://media.prothug.com/2013/05/wpid-Featured1.png
我没有也不能,我已经尝试了很多东西,明白为什么“li”和“ul”之间有那个空白。
这是我为特色图片获得的 html——
<div id="featured-boxes">
<ul class="featured-boxes-ul">
<li>
<a href="http://example.com">
<img src="lemon.jpg" alt="Featured Post 1" />
<p class="featured-boxes-caption">Little Johnny</p>
</a>
</li>
<li>
<a href="http://example.com">
<img src="lemon.jpg" alt="Featured Post 2" />
<p class="featured-boxes-caption">Shrieking Banshee</p>
</a>
</li>
<li>
<a href="http://example.com">
<img src="lemon.jpg" alt="Featured Post 3" />
<p class="featured-boxes-caption">Little Johnny</p>
</a>
</li>
<li>
<a href="http://example.com">
<img src="lemon.jpg" alt="Featured Post 4" />
<p class="featured-boxes-caption">Shrieking Banshee</p>
</a>
</li>
<li>
<a href="http://example.com">
<img src="lemon.jpg" alt="Featured Post 5" />
<p class="featured-boxes-caption">Little Johnny </p>
</a>
</li>
<li>
<a href="http://example.com">
<img src="lemon.jpg" alt="Featured Post 6" />
<p class="featured-boxes-caption">Shrieking Banshee</p>
</a>
</li>
</ul>
</div>
这就是它的css——
#featured-boxes {
float: left;
width: 100%;
margin: 0 0 2em;
}
.featured-boxes-ul {
float: left;
width: 100%;
list-style: none;
margin: 0;
padding: 0;
background:#777;
}
.featured-boxes-ul li {
float: left;
position: relative;
width: 32.7%;
min-height: 50px;
margin: 0.3em 0;
}
.featured-boxes-ul li:nth-child(2), .featured-boxes-ul li:nth-child(5) {
margin-left: 0.95%;
margin-right: 0.95%;
}
.featured-boxes-ul a {
display: block;
outline: 0;
}
.featured-boxes-ul a:hover {
text-decoration: none;
}
.featured-boxes-ul img {
display: block;
width: 100%;
margin: 0;
padding: 0;
background: #fff;
}
.featured-boxes-caption {
position: absolute;
width: 100%;
margin: 0;
padding: 10px 0;
bottom: 0;
color: #fff;
font-size: 1em;
line-height: 24px;
text-indent: 30px;
background: rgba(34, 34, 34, 0.5);
z-index: 10;
}
“li”元素的宽度以及第 2 和第 5 个“li”元素周围的左右边距加起来总共为 100%。我已经尽我所能,我确信“ul”在右侧没有任何填充。如果我将“li”变小,并使第 2 个和第 5 个“li”子节点的边距非常大,比如 10%,那么整个特色图像会占据整个“div”,而不会在图像和“乌尔”。问题似乎是浏览器无法准确计算小边距。
我的css有什么问题吗?任何帮助,将不胜感激。