Question

I have some DIV elements that I would like to have a rollOver effect on, but I don't know where to start or if this can be achieved in CSS or with jQuery or even at all.

I have attached an image below:

Example

  1. The normal state is just an image

  2. On rollOver I want the overlay to animate in from right to left.

  3. The "over" state is a trinangle (90% opacity) with some text on.

Any suggestions on where to start?

Was it helpful?

Solution

Sure you can:

HTML:

<div class="img">
    <img src="http://i.stack.imgur.com/TOVE8.jpg" />
    <div class="overlay">
        <span class="bg"></span>
        <span class="txt">Name<br/>Surname</span>
    </div>
</div>

CSS:

.img {overflow: hidden; height: 360px; width: 240px; position: relative;}

.overlay {position: absolute; height: 100%; width: 100%; top: 0; left: 100%;
  -webkit-transition: left 1s ease-out;  
     -moz-transition: left 1s ease-out;
       -o-transition: left 1s ease-out;
          transition: left 1s ease-out;
}

.img:hover .overlay {left: 0;}

.bg {height: 600px; width: 600px; top: 50px; left: 90px;background: #000; position: absolute; display: block;
  -webkit-transform: rotate(34deg);
     -moz-transform: rotate(34deg);
      -ms-transform: rotate(34deg);
       -o-transform: rotate(34deg);
          transform: rotate(34deg); 
}

.txt {color: #fff; font-size: 30px; top: 250px; left: 100px; position: absolute;}

DEMONSTRATION

OTHER TIPS

I'd try to do it CSS only:

  • Make the info image twice as wide as the artist and the left 50% transparant.
  • Hide the info image under a div on the right with higher z-index.

CSS:

img.info:hover {
  margin-left: -100px;
  transition: 1s;
}

Take a look http://jsfiddle.net/nfZK4/

<div id="container">
<div id="wrapper">
    <div id="image"></div><div id="overlay"></div>
</div> 
</div>

and

#container{
  width: 300px;
  height: 500px;
  overflow: hidden;
}
#wrapper{
  width: 600px;
  height: 500px;
  position: relative;
}
#image{
  background: lightgreen;
  width: 300px;
  height: 500px;
  display:inline-block;
}
#overlay{
  width: 300px;
  height: 500px;
  background-image: url('http://i.imgur.com/JgBlqTk.png');
  position: absolute;
  top: 0;
  left: 300px;
  transition: all 1s;
}
#container:hover #overlay{
  left:0;
}

The topmost div hides the triangle from sight with overflow:hidden. when the cursor hovers on the top div, the triangle moves in. with left:0 and a transition to animate it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top