[英]Extend image 100% width beyond parent
所以我試圖將這些幻燈片圖像擴展到容器的父元素1024px之外。 我嘗試將img選擇器,內聯樣式等都設置為max-width:100%。 我可以輕松地將圖像的寬度設置為100%,但是這也將容器設置為我不想要的100%。 我希望容器元素保持不變,但只使圖像成為容器的100%。
JSFiddle: http : //jsfiddle.net/schermerb/tK6H9/1/
<div class="main-inner">
<div class="slider">
<img alt="" src="images/slide1.jpg" />
<img alt="" src="images/slide2.jpg" />
<img alt="" src="images/slide4.jpg" />
</div>
</div>
.main-inner {
position: relative;
width: 1024px;
height: 475px;
margin: auto;
}
.slider {
width: 100%;
height: 475px;
}
.slider img {
width: 100%;
height: 475px;
margin: 0;
position: absolute;
}
/* SLIDER CONTAINER */
.slider-container {
width: 1024px;
margin: auto;
height: 475px;
}
.previous-btn, .next-btn {
position: absolute;
top: 200px;
width: 35px;
height: 60px;
margin: auto;
}
.previous-btn {
left: 0;
background: url(images/prev.png);
}
.next-btn {
background: url(images/next.png);
right: 0;
}
/* PAGiNATION */
.pagination {
position: absolute;
top: 450px;
right: 6px;
margin: auto 0;
padding: 0;
}
.pagination li {
list-style: none;
float: left;
margin: 0 5px;
width: 15px;
height: 15px;
position: relative;
}
.pagination li a {
position: absolute;
width: 15px;
height: 15px;
background: #fff;
text-indent: -9999px;
display: block;
opacity: 10;
}
.pagination li.current-pagination a, .pagination li a:hover {
opacity: 0.9;
background: #00a1f1;
}
好了,所以做了一些小的更改。
為了防止從大圖像滾動:
body {
overflow-x: hidden;
}
要獲得所需大小的圖像:
.slider img {
width: 1900px;
height: 475px;
left:50%;
margin: 0 auto;
margin-left: -950px;
position: absolute;
}
最后,添加overflow:visible;
在.slider
,以避免圖像在您的原型上被剪切。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.