[英]Parent element is adding unnecessary whitespace
I am making an image slider and for some reason the parent element is adding whitespace at the bottom of parent div for no reason that I can tell. 我正在制作图像滑块,由于某种原因,父元素无缘无故告诉父div底部添加了空格。 If there is a better way to set up the css then I would really appreciate a pointer.
如果有更好的方法来设置CSS,那么我真的很感谢一个指针。 Here is the code:
这是代码:
HTML: HTML:
<div id="imgslider">
<ul class="bxslider">
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-11.jpg" alt="" />
</li>
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-1.jpg" alt="" />
</li>
</ul>
<div class="clear"></div>
CSS: CSS:
#imgslider {
display: block;
height: inherit;
}
.bxslider {
position: relative;
}
.bxslider img {
width: 100%;
max-height: 750px;
position: absolute;
}
.bxslider img:first-child {
top: 0;
left: 0;
z-index: 1;
}
There is a not closed div at the end :-) Maybe this is what causing the issue: 末尾有一个未关闭的div :-)也许这是导致问题的原因:
<div id="imgslider">
<ul class="bxslider">
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-11.jpg" alt="" />
</li>
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-1.jpg" alt="" />
</li>
</ul>
</div>
<div class="clear"></div>
Not sure it will help but i have read somewhere " clear:both " cause adding some space at bottom so you may want to add " overflow:hidden " to the parent div (i think it is the div with id " imgslider ") 不确定是否会有所帮助,但是我已经读过“ clear:both ”,在底部添加了一些空间,因此您可能想向父div添加“ overflow:hidden ”(我认为它是ID为“ imgslider ”的div)
#imgslider {
display: block;
height: inherit;
overflow:hidden;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.