Reputation: 5
I have already looked here (How to show text on image when hovering?) to find a solution to this problem but it doesnt 100% work... Because the paragraph is located below the image part of the image is not covered when you hover over it. I want the whole image covered by the text when you hover over the image. (Look at this: http://jsfiddle.net/rMhGE/ or below.)
The HTML
<body>
<div class="cube1">
<a href="http://google.com"><img src="http://us.123rf.com/400wm/400/400/busja/busja1209/busja120900010/15099001-detailed-vector-image-of-symbol-of-london--best-known-british-double-decker-bus.jpg">
<p class="contact">Random Text Here</p></a>
</div>
</body>
The CSS
.cube1 {
position: relative;
width: 400px;
height: 400px;
float: left;
}
.contact {
overflow: hidden;
position: absolute;
width: 400px;
height: 386px;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(255,255,255,0.95);
color: #aaa;
visibility: hidden;
opacity: 0;
}
.cube1:hover .contact {
visibility: visible;
opacity: 1;
}
Any help is appreciated. Thank you.
Upvotes: 0
Views: 5756
Reputation: 3775
change the p {margin:0px}
of the p element
or give the class
.contact {
overflow: hidden;
position: absolute;
width: 400px;
height: 395px;//change height also to cover it completly
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(255,255,255,0.95);
color: #aaa;
visibility: hidden;
opacity: 0;
margin:0px
}
Upvotes: 3
Reputation: 4560
Remove the height from contact. as well as the margin. You also don't need the width value if you're stretching it with the absolute 0 0 0 0 method.
.contact {
overflow: hidden;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(255,255,255,0.95);
color: #aaa;
visibility: hidden;
opacity: 0;
margin: 0;
}
Upvotes: 3
Reputation: 85653
Remove the height from .contact and apply top: -15px; bottom: -15px;
Alternatively, the best way, set margin: 0;
removing height.
Upvotes: 0
Reputation: 2961
You need to set margin on the "p" element to 0 and the "height" to 400:
margin:0;
height:400px;
Updated jsFiddle: http://jsfiddle.net/rMhGE/5/
Upvotes: 0
Reputation: 8497
The image has the text over it, I am not sure what you are trying to do here. What do you mean by "covering the image"?
Upvotes: 0