可能忽略了一些简单的事情,但问题是浏览器窗口宽度很小时。重叠点放置不正确(图像底部)。
注意:如果从 HTML LI 中删除了“HEIGHT”属性,则不会显示图像。 玩高度:自动;在 HTML/CSS 中具有相同的结果。最大高度具有相同的效果。
我想删除硬编码的 HTML 样式高度,并让点始终出现在图像的底部,无论大小。
小提琴:http : //jsfiddle.net/s3r8uuzz/
JavaScript 文件:
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//unslider.com/unslider.min.js" type="text/javascript"></script>
CSS:
.banner ul {
list-style: none; /* Lose the dot */
margin:0px;
padding:0px;
}
.banner li {
float: left;
background-size: 100% auto;
background-repeat: no-repeat;
}
.dots {
position: absolute;
left: 0;
right: 0;
text-align: center;
bottom: 0px;
background-color: #353535;
height: 35px;
opacity: .7;
}
.dots li {
position:relative;
top:11px;
left:-4px;
display: inline-block;
width: 10px;
height: 10px;
margin-left: 4px;
text-indent: -999em;
border: 2px solid #bc9a6a;
background-color: white;
border-radius: 6px;
cursor: pointer;
-webkit-transition: background .5s, opacity .5s;
-moz-transition: background .5s, opacity .5s;
transition: background .5s, opacity .5s;
}
.dots li.active {
background: #3e245b;
opacity: 1; /* opacity of the inside dot (not the border) */
}
#slider{
position: relative;
}
HTML:
<div id="slider" style="">
<div class="banner">
<ul>
<li style="background-image: url(http://cdn.nliphonedwwwghan.savviihq.com/wp-content/uploads/2013/12/500px1-580x375.jpg); height:350px;"><a href="/testing"></a></li>
<li style="background-image: url(http://cdn.nliphonedwwwghan.savviihq.com/wp-content/uploads/2013/12/500px1-580x375.jpg); height:350px;"><a href="testing"></a></li>
</ul>
</div>
</div>
<div>
No matter the window size, this text should be directly under the image.
</div>
<script>
// main image settings
$('.banner').unslider({
arrows: false,
delay: 2000,
fluid: true,
speed: 1000,
dots: true
});
</script>