My HTML code is shown below:
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="span7">
<div class="home-image left-image">
<img class="photography-left-top" src="http://placehold.it/700x440" />
<p class="image-text_left">Wedding Photography</p>
</div>
<h5>Heading</h5>
</div>
<div class="span5">
<div class="home-image right-image right-image-top">
<img class="photography-right-top" src="http://placehold.it/400x200" />
<p class="image-text_right-top">Fashion Photography</p>
</div>
<div class="home-image right-image right-image-bottom">
<img class="photography-right-bottom" src="http://placehold.it/400x200" />
<p class="image-text_right-bottom">Contact</p>
</div>
<h5>Heading</h5>
</div>
</div>
</div>
This is the CSS I have used:
.home-image {
position:relative;
}
.photography-left-top,.photography-right-top,.photography-right-bottom {
position : absolute;
}
.image-text_left {
display:none;
position:absolute;
width:300px;
top:200px;;
left:200px;
z-index : 100;
font-weight:bold;
}
.image-text_right-top,.image-text_right-bottom {
display:none;
position:absolute;
width:300px;
top:100px;
left:100px;
z-index : 100;
font-weight:bold
}
.right-image-bottom {
margin-top:220px;
position:relative
}
.right-top {
position:relative
}
.home-img-hover {
background:#911717;
}
JavaScript:
$(document).ready(function(){
$(".left-image").hover(function () {
$(this).find('.photography-left-top').fadeTo('slow',0);
$(this).addClass('home-img-hover');
$('.image-text_left').show();
},
function () {
$(this).find('.photography-left-top').fadeTo('400',1.0);
$('.image-text_left').hide();
});
I expected a background color when hovering over left-image
due to the addClass('home-img-hover')
, but it is showing a white default background instead. Why is this happening?