I'm having an issue with creating a navigation system on my website. Once you hover over the navigation it extends to fit the categories of the website which are in a ul. I know what the issue is, because the width of the parent of the ul is too small to contain the text, the text has to shrink before the transition.
So I was wondering, is there a way to transition the text in once the width is done animating. Or are there any other solutions?
CSS:
.navigation {
width: 3.5vw;
height: 7vh;
background-color: #fcc101;
margin: 1vw;
border-radius: 4rem;
font-family: 'Work Sans', sans-serif;
transition: all 1s ease-in;
background-image: url('menu.svg');
background-size: 30px;
background-repeat: no-repeat;
background-position: center center;
position: fixed;
}
.navigation .ul a {
visibility: hidden;
opacity: 0;
transition: all 1s ease-in-out;
}
.navigation .ul {
visibility: hidden;
}
.navigation:hover {
width: 25vw;
border-radius: 3rem;
background-image: none;
background-size: 30px;
background-repeat: no-repeat;
background-position: center center;
}
.navigation:hover ul a {
opacity: 1;
visibility: visible;
}
li {
display: inline;
}
a {
color: white;
text-decoration: none;
font-size: 1.25rem;
}
.ul {
text-align: left;
line-height: 7vh;
padding-left: 2vw;
word-spacing: 1vw;
}
Here is the site.
Thanks.
One solution could be to apply an animation-delay to your ul which is >= your other animations run time. This way the animation should only fire once the other one has completed.
animation-delay: 3s;
Something similar to the above should work just fine.
Or, if you are using transitions then you can use the transition-delay property instead!
transition-delay: 3s;
Well, I spotted a couple of issues with your animation!
The first issue is, that the "contact" menu item shows up under the other menu items and that when the animation is still in progress, the menu items get under each other.
To fix this issue you need to add this:
.navigation .ul {
visibility: hidden;
position:absolute; /* We need a position absolute so it won't be effected by the size of the parent div */
width:400px; /* Set the width to whatever works for you */
}
As for delaying the animation, you can add this:
.navigation .ul {
visibility: hidden;
position:absolute; /* We need a position absolute so it won't be effected by the size of the parent div */
width:400px; /* Set the width to whatever works for you */
-webkit-transition-delay: 2s; /* You can set the delay to whatever you need */
transition-delay: 2s; /* You can set the delay to whatever you need */
}
I also think that you should maybe make the animation a bit faster and more fluid, and maybe have it on click instead of on hover.
Related
I was able to make to rectangle surrounding my links expand as I wanted but it's a bit too fast
My new code is this:
a:link, a:visited {
background-color: #F2AA52;
color: white;
padding: 14px 25px;
text-align: left;
text-decoration: none;
display: inline-block;
margin: 0px;
}
a:hover {
width: 100%;
transition-duration: 1s;
}
I'm almost done with this but it goes to 100% width a little too fast, is there a way to make it go smoother? (instead of it going from 30% width to 100% width instantly, being able to see it progressively getting bigger in like 1.5s?)
a:link, a:visited {
background-color: #F2AA52;
color: white;
padding: 14px 25px;
text-align: left;
text-decoration: none;
display: inline-block;
margin: 0px;
width: 30px;
transition: all 0.3s ease;
}
a:hover {
width: 100%;
}
<a href='google.com'>Hi</a>
Check this out, I have replaced the padding with width. Hence the transition is working as expected
I tried using the transition: all 0.3s ease; line but it still won't give me a smooth transition, it goes from "base state" to "100% width" instantly, even though it works in your code snippet.
EDIT: now i got it working i had to give it a base width for it to work as i wanted. Thank you!
Is there a way to change my question to "Resolved"?
Hey I made a small hover effect but there is a bug in it which I seem not to be able to remove by myself, so hopefully someone can help me :(
[here]https://jsfiddle.net/5a4jh4pc/
this is the hover effect.
The hover width is not arranged to 100% of the image size
The hover effect even starts if you are close to the image on the right side. (it should only do the effect when the mouse is ON the image, not next to it.)
I hope someone can help me here to fix this. Thanks in advance!
You have your container set to a certain size, which the hover effect is triggered over, and the image is set to 70% of this.
This means that you have 30% of the container to the right still activating the hover, but containing no image.
Change the figure width to suit your needs
figure {
display: inline-block;
position: relative;
float: left;
overflow: hidden;
width: 300px;
}
figcaption {
position: absolute;
background: black;
background: rgba(0,0,0,0.75);
color: white;
opacity: 0;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
font-size: 12px;
line-height: 15px;
}
figure:hover figcaption {
opacity: 1;
}
figure:hover:before {
opacity: 0;
}
.cap-bot img {
float:left;
width:100%;
}
.cap-bot:before { width:0%;padding: 10px 10px;bottom: 10px; }
.cap-bot figcaption { width:100%;padding: 10px 10px;left: 0; bottom: -30%;}
.cap-bot:hover figcaption {width:100%;padding: 10px 10px;bottom: 0; }
Forked https://jsfiddle.net/hjhbrosh/
Remove left and right padding in your figcaption and use word-wrap: break-word; to wrap the text to the next line when it overflows and use a div inside your figcaption to retain that padding.
.cap-bot figcaption {
width:70%;
padding: 10px 0px;
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
width:70%;
padding: 10px 0px;
bottom: 0;
}
Check this fiddle
I'm using transition property in CSS in the navigation on my website. The navigation consists of 3 images. When you hover the image with the mouse, a transition is applied that displays an overlay with some text. This all works beautifully in Chrome and Firefox. Safari, however, is a mess. Not only does the transition behaviour not work at all, but no matter what I do, the menu stays on a second line rather than remaining on the first line with the logo (you'll see from the jsfiddle example what I mean if you open the fiddle in both Chrome and Safari).
CSS:
header nav a img {
width: 100%;
transition: all 0.2s ease-in-out;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
}
.menuitem-content {
top: 15px;
padding: 5px;
margin: 0 auto;
width: 100%;
height: 100%;
position: absolute;
text-align: center;
vertical-align: middle;
color: #FFFFFF;
background-color: rgba(86, 81, 65, .8);
display: none;
transition: all 1.2s;
-webkit-transition: all 1.2s;
-moz-transition: all 1.2s;
font-size: 14pt;
z-index: 999;
left: 0px;
}
header nav a:hover > .menuitem-content {
display: inline-flex;
}
https://jsfiddle.net/35qnu4d1/
You might have to expand the output window a bit to see the menu and logo on the same line (which for our purposes is fine as the min resolution should be 1024x768 — this isn't build for mobile devices). Any ideas why it's behaving so weird in Safari?
Use http://caniuse.com/#search=flex, you need -webkit-... vendor prefixes for all flex properties.
display isn't animatable property. You can't apply transition to it. See this list of animatable CSS properties.
You don't need to use display: inline-flex with position: absolute — display: block is enough.
Check out my JSFiddle.
CSS:
header {
width: 100%;
background-color: #565141;
overflow: hidden;
display: -webkit-flex;
display: flex;
}
header nav a:hover > .menuitem-content {
display: block;
}
#content-body {
background-color: #efefef;
width: 97%;
padding: 15px;
display: -webkit-flex;
display: flex;
}
footer {
width: 100%;
background-color: #565141;
display: -webkit-flex;
display: flex;
}
I have these two images with corresponding labels: http://jsfiddle.net/Fdjtc/
I want to make it so that when I hover over one of the divs, the image animated downward and the text (initially invisible) animated downward and fades to full opacity, making the images and labels look like they do right now. How can I make sure that the images have enough space upwards to do this, and can I do this kind of animationg using CSS3's transition?
Are you looking for something like this:
http://jsfiddle.net/Fdjtc/9/
There are several ways of doing this. This example is using absolute positioning with transitions on top/bottom.
CSS:
div.wrap > img {
display: block;
position: absolute;
width: 200px;
top: 20px;
left: 20px;
-webkit-transition: top 500ms;
}
div.wrap:hover > img {
top: 5px;
}
div.wrap > span {
display: block;
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
opacity: 0;
-webkit-transition: bottom 500ms;
}
div.wrap:hover > span {
bottom: 2px;
opacity: 1;
}
Edit: (after your dynamic size request)
This is another way of doing it, using margins. Text caption is a bit of problem here but you will get the idea.
Updated Fiddle: http://jsfiddle.net/Fdjtc/11/
CSS:
div.wrap {
float: left;
text-align: center;
margin: 4px;
border: 1px solid gray;
}
div.wrap > img {
display: block;
text-align: center;
margin: 16px;
-webkit-transition: margin-top 500ms;
}
div.wrap:hover > img {
margin-top: 2px;
}
Based on what you wrote, I've came up with this for you:
http://jsfiddle.net/Fdjtc/6/
I've made quite a noticeable change to your html, too:
<div>
<img src="http://placekitten.com/256">
<span>Label 1</span>
</div>
Hopefully this is what you wanted, if not, please extend your question and be more descriptive.
Is this what you wanted to achieve ?
.box img
{
-webkit-transition:all 0.5s ease-in-out;
height:200px;
display:block;
margin-top:-200px;
}
.box:hover > img
{
margin-top:0px;
}
http://jsfiddle.net/4BtcR/
I have an animation on my site which goes from width: 100px to 800px when hover on.
But when hover out, it just goes to the normal position with no animation.
How could I get it so the animation would go back on hover-out the same way it came on hover?
I only found solutions for transitions, but I need it for animation.
<div id="blackbox"/>
<div id="blacktxt">
Navigation
</div>
See Here
Why not use transitions instead of animations? Working jsFiddle
#blackbox {
background: black;
width: 100px;
height: 80px;
color: white;
text-align: center;
font-family: Times;
font-size: 20px;
position: fixed;
left: 0px;
bottom: 100px;
opacity: 0.5;
margin-bottom: 10px;
transition: all 2s; /* Add this transition */
}
#blackbox:hover { /* Apply the new design on hover */
opacity: 0.8;
width: 800px;
}
#blacktxt {
margin-top: 10px;
height: 60px;
transition: opacity 0.5s, width 5s;
position: absolute;
font-family: cursive;
cursor: default;
}
#blacktxt:hover {
opacity: 0;
}
I wrote the jQuery Reversible plugin for this. Its main advantage over CSS transitions is that it works on IE9 and older browsers.