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:
The normal state is just an image
On rollOver I want the overlay to animate in from right to left.
The "over" state is a trinangle (90% opacity) with some text on.
Any suggestions on where to start?
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;}
I'd try to do it CSS only:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.