I currently have a grid of images with a 'greyscale to colour' and 'zoom' effect applied. The zoom effect is expanding outside the container. I have applied overflow: hidden
(a couple of times) and set a max-width
. However, these attempts have been unsuccessful. Here is my JSFiddle .
HTML
<div class="content">
<ul class="rows">
<li>
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="50%" height="auto" style="float:left"></a>
</li>
<li>
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="50%" height="auto" style="float:left"></a>
</li>
<li>
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="50%" height="auto" style="float:left"></a>
</li>
<li>
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="50%" height="auto" style=" float:left"></a>
</li>
<li>
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="50%" height="auto" style="float:left"></a>
</li>
<li>
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="50%" height="auto" style="float:left"></a>
</li>
</ul>
</div>
CSS
.content {
width: 100%;
height: auto;
min-height: 100%;
}
.rows {
list-style: none;
overflow: hidden;
width: 100%;
}
.rows li a img {
max-width: 100%;
overflow: hidden;
}
.rows a img {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
-webkit-filter: grayscale(100%) opacity(0.7);
filter: grayscale(100%) opacity(0.7);
}
.rows a img:hover {
-webkit-transform: scale(1.2);
transform: scale(1.2);
-webkit-filter: grayscale(0) opacity(1);
filter: grayscale(0) opacity(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
Container of images is a
tag, so you should set overflow: hidden
on this element:
.rows li a {
float: left;
width: 50%;
overflow: hidden;
}
Add above code to your css and set all your images width in html to 100%
:
<a href="#"><img src="http://lorempixel.com/400/200/" alt="Case Study" width="100%" height="auto" style="float:left"></a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.