I wrote some CSS to cause a sidebar to do a slide transition from off the page to visible when you mouse over the side of the page. The CSS is simple and involves adding/removing a class that controls the left: position of the sidebar.
#sidebarInner{
height:100%;
width:50px;
background-color:blue;
position: fixed;
-moz-transition: left .2s linear;
-webkit-transition: left .2s linear;
-o-transition: left .2s linear;
transition: left .2s linear;
z-index:2;
}
.slideLeft {
left: -100px;
}
Try the following demo on a webkit browser and on Firefox:
http://jsfiddle.net/MmFnY/7/
You'll notice on webkit, the blue colored div has the 0.2s slide left transition but on Firefox it does not. Does anyone know whats wrong with the CSS above?
In order for the transition to work you need to provide it with a default left value. Easiest way to do this is probably to give it another class for when it's inside such as:
.slideRight{
left: 0px;
}
http://jsfiddle.net/MmFnY/19/
Related
For example I have an element e.g. image with next css:
img{
width:400;
height:285;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
-webkit-backface-visibility: hidden;
}
img:hover{
transform: scale(1.04,1.04);
-ms-transform: scale(1.04,1.04);
-webkit-transform: scale(1.04,1.04);
}
On this image I have absolute banner that appears on image hover and moves according to image offset position, thus on image scaling the offset of the image is changed and my banner get "zoomed" image offset instead of normal one. I'd like to calculate divergence in pixels in order to reduce this value from the absolute banner left and top css values.
I've tried this solution, but it seems to be not working properly.
Thanks for the help
I want something like picture links in bottom of this site.Any body know whats the effect of the site or please suggest to me some javascript code example or library to make picture up/down on mouse hover and make some beautiful tooltip too.
You only need CSS, and on hover change the margin:
img {
margin-bottom: -75px;
margin-top: 20px;
padding-right: 40px;
-webkit-transition: margin 0.5s ease;
-moz-transition: margin 0.5s ease;
-o-transition: margin 0.5s ease;
-ms-transition: margin 0.5s ease;
transition: margin 0.5s ease;
}
img:hover {
margin-top: -20px;
}
This code is basically copied from the site you've provided. I would be careful by using it as is. Take it only as an example.
On the mobile phone, there is a dropdown menu on the navbar. But it is far too slow.
Is it JQuery based? Or is it CSS transition based? How do I speed it up?
It is CSS transition based, try changing the height value from the transition property of this class.
.collapsing {
position: relative;
height: 0;
overflow: hidden;
-webkit-transition: height .35s ease;
-o-transition: height .35s ease;
transition: height .35s ease;
}
I'm using the Foundation framework on a project & it's Top Bar feature for navigation allows for drop-down navigation to appear on hover.
During the hover event it adds a .hover class to the relevant element, therefore the changes in CSS pop into sight rather than animating by way of a smooth transition.
This got me thinking. Is it possible to animate (via transitions or similar) the changes in CSS definitions?
Take this example. Here is our default element:
<div class="a-box">Some content</div>
And it's default CSS:
.a-box {
width: 200px;
height: 200px;
background: red;
}
On hover the framework (which I do not wish to edit the core file to keep it clean for updates) adds the hover class. Making our element now look like this:
<div class="a-box hover">Some content</div>
Here could be some CSS for the hovered element:
.a-box.hover {
width: 400px;
// I thought perhaps adding the following would work but it doesn't appear to
-webkit-transition: all 200ms ease;
-moz-transition: all 200ms ease;
-ms-transition: all 200ms ease;
transition: all 200ms ease;
}
I'd be keen to hear others POV on this! I'm not sure if this is a duplicate, but all the posts I've read relate to some form of jQuery animation.
You aren't far off the mark, here is a working example.
The main error in your example is that you have
<div class="my-box hover">Some content</div>
But your CSS is looking for a-box not my-box.
As a habit, I normally define the animation on the simplest (most general) selector for the element and then any additional selectors will benefit from it.
.my-box {
width: 200px;
height: 200px;
background: red;
-webkit-transition: all 200ms ease;
-moz-transition: all 200ms ease;
-ms-transition: all 200ms ease;
transition: all 200ms ease;
}
.my-box.hover {
width: 400px;
}
Im attempting to build a series of thumbnails that enlarge on hover. My preliminary build accomplishes the enlarge/zoom part by using CSS3 transform:scale and ease-in-out. The problem is that they overlap each other because they share a single z-axis.
Can anyone assist me in creating a javascript addition to this scenario that correctly positions each thumbnail in a z-axis that makes sense, i.e. each enlarged image resizes to be on top of each other image.
Demonstration on my website here: demo Updated: Solved
Preview of code:
html:
<div style="position: absolute;" class="item hover">
<img alt="two" src="img/posts.png">
</div>
css:
#main div.hover {
position: relative;
z-index:200;
display: block;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
background-color: #297ab1;}
#main div.hover:hover, #main div.hover_effect {
-webkit-transform:scale(1.5, 1.5);
-moz-transform:scale(1.5, 1.5);
-o-transform:scale(1.5, 1.5);
-ms-transform:scale(1.5, 1.5);
transform:scale(1.5, 1.5);}
script:
$(document).ready(function() {
$('.hover').bind('touchstart touchend', function(e) {
e.preventDefault();
$(this).toggleClass('hover_effect');
});
});
So this page uses this script to toggle the hover_effect class that increases the div's scale to 150%.
Solution: z-index:999
Also any ideas about putting a delay in the initial mouseenter without a setTimeOut?
Any suggestions and solutions are most appreciated!
p.s. This demo uses a modified version of masonry image gallery.
Thanks.
Untested:
#main div.hover:hover, #main div.hover_effect {
z-index: 999
}