CSS3 Animation multiple hover - html

I have 2 divs. When I hover the mouse over one div it expands changing the height. I want to make it display a text with fade in effect somewhere in the screen when I hover the mouse over that div and finally when I click on the div, I want to display another div or text somewhere in the screen again. This is the code I've created so far.
<style>
#container
{
width:212px;
position:fixed;
left:42.5%;
top:21.7%;
border: 0px solid red;
overflow: hidden;
}
#first
{
background-color:#fff;
width:67px;
height:212px;
-webkit-transition:all 1s, -webkit-transform 1s; /* For Safari 3.1 to 6.0 */
-moz-transition:all 1s, -webkit-transform 1s;
-ms-transition:all 1s, -webkit-transform 1s;
-o-transition:all 1s, -webkit-transform 1s;
transition:all 1s, -webkit-transform 1s;
transition:all 1s, transform 1s;
float:left;
}
#first:hover
{
height:354px;
}
#second
{
background-color:#fff;
width:45px;
height:212px;
-webkit-transition:all 1s, -webkit-transform 1s; /* For Safari 3.1 to 6.0 */
-moz-transition:all 1s, -webkit-transform 1s;
-ms-transition:all 1s, -webkit-transform 1s;
-o-transition:all 1s, -webkit-transform 1s;
transition:all 1s, -webkit-transform 1s;
transition:all 1s, transform 1s;
float:left;
margin-left:15px;
}
#second:hover
{
height:354px;
}
</style>
<div id="container">
<div id="first"></div>
<div id="second"></div>
</div>
Any ides ? :/

Do you mean something like this?
http://jsfiddle.net/vLz3c/1/
I've created a pargraph inside the #second element, and made that show up while you hover the #second element.
It also increases the height.
EDIT:
http://jsfiddle.net/vLz3c/2/
Now i have used the jQuery function fadeIn when hovering the #second box.
EDIT 2:
http://jsfiddle.net/vLz3c/3/
Now the paragraph also fades out, when you move your mouse away from the #second box
EDIT: 3
As promised, when you click the #second element, the #third element fades in.
http://jsfiddle.net/vLz3c/4/

Related

Smooth transition using background images

I am transitioning a couple of background images. However, I am noticing that when if the user acts before the transition has fully taken affect, the transition is instant.
For example, I hover over the div and the image takes 1 second to completely transition. However, I remove the cursor .5s into the transition. So it transitions back to the original image but instead of smoothly transitioning, it changes instantly. How do I make it smooth at all times?
.class {
width:500px;
height:500px;
background-image:url("http://activite-paranormale.net/extended/photo/news/nature-harmony-girl.jpg");
-webkit-transition: all 1s ease 0;
-moz-transition: all 1s ease 0;
-o-transition: all 1s ease 0;
transition: all 1s ease 0;
}
.class:hover {
background-image:url("http://images4.fanpop.com/image/photos/22700000/Spring-beautiful-nature-22727146-500-500.jpg");
}
<div class="class"></div>
http://codepen.io/john84/pen/vEdPEW
fiddle
I changed ease to ease-in-out
edit: Firefox doesn't support this, but there are many workarounds, example:
fiddle
HTML:
<div class="class"></div>
<div class="class2"></div>
CSS:
.class {
position:absolute;
width:500px;
transition:all 500ms;
height:500px;
background-image:url("http://activite-paranormale.net/extended/photo/news/nature-harmony-girl.jpg");
}
.class2{
width:500px;
height:500px;
background-image:url("http://images4.fanpop.com/image/photos/22700000/Spring-beautiful-nature-22727146-500-500.jpg");
}
.class:hover {
opacity:0;
}

Fit Div to page?

I'm trying to make hover images and add a link to the div but the div does not fit to page.
For example:
http://test.peterstavrou.com/
See how the image gets cut off?
Anyone have any ideas?
Below is my code.
CSS
#cf {
position:relative;
margin:0 auto;
}
#cf img {
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#cf img.top:hover {
opacity:0;
}
HTML:
<div id="cf"><img class="bottom" src="http://www.peterstavrou.com/wp-content/uploads/2014/11/eBay-Listing-Template-Price.jpg" alt="eBay Template Listing" width="292" height="311" /><img class="top" src="http://www.peterstavrou.com/wp-content/uploads/2014/11/eBay-Listing-Template.jpg" alt="eBay Template Listing" width="292" height="311" /></div>
<strong>Summary:</strong> TEST TEST TEST
<a title="eBay Template Listing" href="http://www.peterstavrou.com/product/ebay-listening-template/">Click here for more information.</a>
jsFiddle http://jsfiddle.net/hz80govj/
the div only contains an image, so it's width/height is derived from that image width/height, which is currently set to width="292" height="311".
If you want the div/image to adjust to screen size, remove the width/height from the image and set image size using css:
img{
max-width: 100%;
}
Your question is not at all clear, But as I understood you need to fit the div to the size of the picture. If I am correct use the following CSS.
#cf {
position:relative;
float:left;
margin:0 auto;
}
.top {
position:absolute;
left:0;
-webkit-transition:opacity 1s ease-in-out;
-moz-transition:opacity 1s ease-in-out;
-o-transition:opacity 1s ease-in-out;
transition:opacity 1s ease-in-out;
}
#cf img.top:hover {
opacity:0;
}
.bottom {
position:inherit;
}

I can't move the logo on my website

I've been writing this website for a few days now and have gotten into trouble with my logo position. I can't seem to move it not matter how much I try. Can anyone suggest how I can do this? PS. (I'm still learning css.)
HTML:
<div class="logofx">
<img src="images\logo.png">
</div>
CSS:
.logofx img {
top:300px;
left:50px;
-webkit-transition: all 5s ease;
-moz-transition: all 5s ease;
-o-transition: all 5s ease;
-ms-transition: all 5s ease;
transition: all 5s ease;
}
.logofx img:hover {
-webkit-filter: hue-rotate(333deg);
}
You need position:relative, position:absolute or position:fixed (depending on the specific desired effect*).
By default, elements have position:static and statically-positioned elements are unaffected by left/top/right/bottom adjustments.
*Effects:
position:relative moves the element by the amount specified, but other elements behave like it hasn't moved. If you want other elements to move too, consider using margin properties instead.
position:absolute moves the element to be placed relative to the nearest position:relative container (or the whole document, if there is none).
position:fixed fixes the element in the browser window, using the left/top as coordinates.
Set position: fixed
.logofx img {
position: fixed;
top:300px;
left:50px;
-webkit-transition: all 5s ease;
-moz-transition: all 5s ease;
-o-transition: all 5s ease;
-ms-transition: all 5s ease;
transition: all 5s ease;
}
what about margins instead?
.logofx img {
margin:300px 0 0 50px;
display:block;
-webkit-transition: all 5s ease;
-moz-transition: all 5s ease;
-o-transition: all 5s ease;
-ms-transition: all 5s ease;
transition: all 5s ease;
}
HTMl:
<div class="logo"><div class="logofx">
<img src="images\logo.png">
</div>
</div>
CSS:
.logo{position:relative;}
.logofx{position:absolute; top:10px; left:10px;}
Try this code this will help you .Kindly put the top and left at correct pixel or move where you want using top and left property.

Animation in css3

I just created an css3 animation and I have a problem.
When I hover over my text, above appear a line and everything may have to be great, but I don't know how to move this line at the bottom of text.
I've trying with transform:translateX but it does not help.
There is my code:
.line
{
font-family:Tahoma;
width:0px;
height:1px;
background:black;
transition:width 0.4s ease ;
-moz-transition: 0.4s ease ; /* Firefox 4 */
-webkit-transition: 0.4s ease ; /* Safari and Chrome */
-o-transition: 0.4s ease; /* Opera */
}
div:hover
{
width:85px;
}
http://jsfiddle.net/DashDesign/SD58Z/1
Move the inner div one pixel to the top, give it an opaque background and remove the height restriction from the parent div.
.line div{
background:#fff;
position:relative;
bottom:1px;
}
Example

CSS Crossfade image

I have this code that works great. When I pass the mouse over the image it crossfades to another image.
What I want is: when I pass over the mouse the image crossfade and rest like this, I mean, make only 1 transition.
1)image 1
2)onmouseover image 2
3)onmouse out image 2
here my code:
<div id="crossfade">
<img class="bottom" src="images/site3/pasarela1.png" />
<img class="top" src="images/site3/pasarela2.png" />
</div>
here my css code:
#crossfade {
position:relative;
height:250px;
width:400px;
}
#crossfade img {
position:absolute;
left:0;
opacity: 1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#crossfade img.top:hover {
opacity:0;
}
From what I get is that you want the :hover state to "stick". Though it's not a pure CSS solution, a solid way to handle this is if you are using jquery's .addClass.
$('.yourimage').mouseover(function() { //hover over your image to trigger the event
$(this).addClass('yourAnimationClass'); //add the animation class to the image you hovered over
});