Skip to content Skip to sidebar Skip to footer

Color Overlay (hover) On Resizing Image

I want to have a color overlay on an image. Now this is pretty simple, but given the fact the image's border changes on hover, it isn't (for me, because I'm fairly new to CSS). I d

Solution 1:

I've updated some code; see http://jsfiddle.net/GR8Vq/:

* {
    margin: 0;
    padding: 0;
}

body {
    background: #000;
}

.imgholder {
    position: relative; // added
    margin: 5px;
    // background: #fff;
    float: left;
    height: 200px;
    // border-radius: 200px / 110px;
    transition: border-radius 0.3s ease-out;
}

.imgholderimg,
.imgholder:after {
    border-radius: 200px / 110px;
    transition: 0.3s ease-out;
}

.imgholder:after {
    content: '';
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(255,255,255,.3);
    opacity: 0;
}

.imgholder:hover:after { opacity: 1; }

.imgholder:hover{
    border-radius: 20px;
}

.imgholder:hoverimg,
.imgholder:hover:after {
    border-radius: 20px;
}

Instead of a border-radius on the image holder, I used a :after selector to add a layer on top of the image. Should be better like this?

Post a Comment for "Color Overlay (hover) On Resizing Image"