我有一个滑块的主页,我目前正在工作。我试图达到一个完整的视口高度,占据了整个屏幕的宽度。
目前我能做到这一点的唯一方法是要么拉伸图像,要么图像不居中。
图像需要在水平和垂直方向上大致居中对齐,这样客户就可以在浏览器的任何宽度上看到图像的中心,而不会过度拉伸图像。
我已经在元素上尝试了background-size: cover;,但没有成功,因为它不是背景img。容器目前有100vh,但宽度是问题所在。
问题位于此处http://joeybox.info/。我意识到与菜单和图像上方的标志100视口高度将休息下的“折叠”,但我把标志和菜单的图像最终,一旦我弄清楚了css。
我已经尝试了在堆栈溢出论坛中找到的许多解决方案,但在我的场景中都不起作用。
在删除错误代码后,我当前的css是:-
.bx-wrapper img {display: inherit;
height: 100vh;
max-width: inherit;}
.ewic-wid-imgs {height: 100vh;
max-width: unset;
width: unset;}
.bx-wrapper img {display: inherit;
height: 100vh;
max-width: inherit;}html=
<div class="slider-box">
<div id="ewic-con-385">
<div style="display: none;" id="preloader-385" class="sliderpreloader">
</div>
<div style="max-width: 100%; margin: 0px auto;" class="bx-wrapper">
<div style="width: 100%; overflow: hidden; position: relative; height: 633px;" class="bx-viewport">
<ul style="width: 315%; position: relative; left: 0px;" class="bxslider-385">
<li style="float: left; list-style: outside none none; position: relative; width: 1349px; margin-right: 10px;" class="ewic-slider bx-clone">
<img title="Qw Direct Leather Keyrings" class="ewic-wid-imgs" src="http://joeybox.info/wp-content/uploads/2015/07/qw-direct-leather-keyrings.jpg">
<div class="ewic-caption"><span>Qw Direct Leather Keyrings</span></div>
</li><li style="float: left; list-style: outside none none; position: relative; width: 1349px; margin-right: 10px;" class="ewic-slider">
<img title="Qw Direct Leather Keyrings" class="ewic-wid-imgs" src="http://joeybox.info/wp-content/uploads/2015/07/qw-direct-leather-keyrings.jpg">
<div class="ewic-caption"><span>Qw Direct Leather Keyrings</span>
</div></li><li style="float: left; list-style: outside none none; position: relative; width: 1349px; margin-right: 10px;" class="ewic-slider bx-clone">
<img title="Qw Direct Leather Keyrings" class="ewic-wid-imgs" src="http://joeybox.info/wp-content/uploads/2015/07/qw-direct-leather-keyrings.jpg"><div class="ewic-caption">
<span>Qw Direct Leather Keyrings</span>
</div></li></ul></div>
<div class="bx-controls bx-has-controls-direction bx-has-controls-auto">
<div class="bx-controls-direction"><a class="bx-prev disabled" href="">Prev</a>
<a class="bx-next disabled" href="">Next</a></div><div class="bx-controls-auto"><div class="bx-controls-auto-item"><a class="bx-start active" href="">Start</a></div>
<div class="bx-controls-auto-item"><a class="bx-stop" href="">Stop</a></div></div></div></div><br>
</div>
</div> 发布于 2015-07-14 19:25:07
要实现这一点,您可以在.BX-wraper中添加您的图像:
.bx-wrapper img {
display: inherit;
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
margin:auto;
max-width: inherit;
}现在您需要将父li设置为relative:
.bx-wrapper ul li {
position:relative;
width:100%;
height:100%;
list-style: none !important;
margin: 0 !important;
}并更改您的父ul:
.bx-wrapper ul{
width:100%;
}发布于 2015-07-15 10:32:59
我已经通过改变图像滑块解决了上面的问题。我的新滑块插件(Envoke Supersized)使用背景图片,更容易使用background-size:cover;css。尽管在此之后,移动宽度上的全视窗高度与我的图像看起来不太好,所以我在移动宽度上使用了40vh。
我建议任何人尝试这样做,以确保您的图像是背景图像,或替换为静态的背景图像浏览器宽度较小的滑块。
https://stackoverflow.com/questions/31405056
复制相似问题