我怎樣才能在div內顯示圖像?請參考下圖,其中只有藍色突出部分內部的圖像部分應該可見,而不應顯示紅色的部分在圖像之間留下空間。僅顯示div內圖像的某些部分
這是jsfiddle。
我也在這裏粘貼了代碼。
.img-sub {
height: 150px;
overflow: hidden;
}
.img-sub img {
height: 100%;
position: absolute;
margin: 0 auto;
left: -100%;
right: -100%;
width: auto;
}
<div class="container-fluid">
<div class="row grid-container">
<div class="col-md-12">
<div class="row">
<div class="col-md-5">
<div class="row img-container img-featured">
<div class="col-md-12">
<a href="/posts/1">
<img class="img-responsive img-thumbnail" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
</div>
</div>
<div class="col-md-7">
<div class="row">
<div class="img-container">
<div class="col-md-4 img-sub">
<a href="/posts/1">
<img class="" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
<div class="col-md-4 img-sub">
<a href="/posts/1">
<img class="" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
<div class="col-md-4 img-sub">
<a href="/posts/1">
<img class="" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
</div>
</div>
<div class="row">
<div class="img-container">
<div class="col-md-4 img-sub">
<a href="/posts/1">
<img class="" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
<div class="col-md-4 img-sub">
<a href="/posts/1">
<img class="" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
<div class="col-md-4 img-sub">
<a href="/posts/1">
<img class="" src="https://i.ytimg.com/vi/JPA_rzHDy6o/maxresdefault.jpg" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@Pete,你可能會注意到,圖像靠得太近。檢查我粘貼的第二張圖像,其中圖像之間有空格。 – basagabi