Color overlay over image on hover
Changing block opacity would also change its content, so you might also try changing alpha channel of the overlay using pseudo elements and rgba()
background color
.image1:hover:after { background-color: rgba(0, 0, 255, 0.3); content: ""; height: 100%; position: absolute; width: 100%;}.image1 { background: url("http://www.avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/images1440/b1.jpg") repeat scroll 0 0 rgba(0, 0, 0, 0); display: inline-block; height: 300px; margin-left: auto; position: relative; vertical-align: top; width: 300px;}
<div class="image1"></div>
Image inside a link that has a color overlay on hover
I would make the container inline-block
so it fits to the size of the image, set the image to vertical-align: top
so the white space at the bottom is gone, then use display: flex; align-items: center; justify-content: center;
on the overlay container to center it's contents.
.img-overlay img { position: relative; vertical-align: top;}
.overlay { display: none; position: absolute; color: #fff; top: 0; bottom: 0; right: 0; left: 0; background-color: rgba(41, 42, 44, 0.5); justify-content: center; align-items: center;}
.img-overlay { position: relative; display: inline-block;}
.img-overlay:hover .overlay { display: flex;}
<a class="img-overlay"> <img src="https://placehold.it/350x150"> <div class="overlay"> <span>TITLE</span> </div></a>
How to create a color-overlay on an image?
You can wrap the image tab with a div tag and set the background color with the rgba code for blue [ex. rgba(34, 167, 240, .5)] Set the opacity of the color by changing the last value of the rgba.
<div class="img-overlay">
<img src="https://images.pexels.com/photos/1093913/pexels-photo-1093913.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=500" alt="Slide Image" class="panel-img">
</div>
.img-overlay {
width: 100%;
height: 100%;
background: rgba(34, 167, 240, .5);
}
CSS Color overlay hover
Here you go, simply reverse the css http://jsfiddle.net/4fgnd/1226/
.image:before {
content:'\A';
position:absolute;
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.image:before {
opacity:1;
}
.image:hover:before {
opacity:0;
}
Related Topics
How to Check If All CSS Files Have Been Downloaded to Insert HTML Using JavaScript
How to Combine Fixed Height Header with Flexible Page Layout
How to Override Inline CSS Through JavaScript
Is There Js Plugin Convert the Matrix Parameter to CSS3 Transform Property
Attempt to Add a Rule to a CSS Stylesheet Gives "The Operation Is Insecure" in Firefox
How to Show One <Div> If JavaScript Enabled and a Different <Div> If It's Not
Bootstrap 4 Input Field in Popover
How to Rotate an Image by a Random Amount Using CSS
JavaScript Style Property Is Empty
Webkit Scrollbar Dynamic Styling
Nav-Collapse Not Working [Twitter Bootstrap]
How to Horizontal Scroll When Scrolling Vertical
How to Start CSS3 Animations at a Specific Spot
Mui Button Hover Background Color and Text Color