1

I am trying to make a hover over text on an image.

Here are to images of the style of hover over I am hoping to achieve

http://imageshack.us/a/img577/7093/cxzy.png (non hover)

http://imageshack.us/photo/my-images/585/l9ka.png/ (hover)

I have been trying so many different ways and none of them seem to be working!

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
race-g-g-g
  • 13
  • 1
  • 4

1 Answers1

4

There are a few ways to do this, but I did it via the :after pseudo element in my example.

jsFiddle here

HTML

<div>
  <img src="..."/>
</div>

CSS

div {
    position:relative;
    display:inline-block;
}
div:hover:after {
    content:"content here..";
    width:100%;
    height:100%;
    background:rgba(0,0,0,.5);
    border:10px solid red;
    position:absolute;
    top:0;
    left:0;
    display:inline-block;
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    box-sizing:border-box;
    text-align:center;
    color:white;
    padding:12px;
    font-size:20px;
} 
FelipeAls
  • 21,711
  • 8
  • 54
  • 74
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
  • Great thanks, but then where do I type in the text that I also want to hover? or do I just type it into the content here area? sorry if this is very basic – race-g-g-g Oct 18 '13 at 02:45