So I've made a responsive navbar in pure CSS and every transition is working when my checkbox is :checked but not the color of the box-shadow of my label that I use as a hamburger button for my checkbox.
I wonder why, can you help me ? I've made a fiddle of my code : the last property in the end of the CSS is the one not working
http://jsfiddle.net/zakL5e8b/1/
#show-menu:checked + .show-menu:before {
background: #9F6C66;
box-shadow: 0 9px 0px 0 #9F6C66, 0 18px 0 0 #9F6C66;
transition: .2s ease-in-out;
-webkit-transition: .2s ease-in-out;
}
Also, the text of my navbar's opacity is animated when my navbar expands but not when it collapses :s here is the propertis not working
#navbar-nav {
visibility: hidden;
opacity: 0;
overflow: hidden;
position: relative;
list-style-type: none;
transition: opacity .2s ease-in-out;
-webkit-transition: opacity .2s ease-in-out;
}
#show-menu:checked + #navbar #navbar-nav {
visibility: visible;
opacity: 1;
transition: opacity .2s ease-in-out .2s;
-webkit-transition: opacity .2s ease-in-out .2s;
}
It's the first time that I trigger events only in CSS via checkboxes :) Thanks in advance !
The problem was in my html and not in my CSS
I had to include the button into the navbar at the end AND precise in my CSS
#show-menu:checked + **#navbar** .show-menu:before {
background: #9F6C66;
box-shadow: 0 9px 0px 0 #9F6C66, 0 18px 0 0 #9F6C66;
transition: .2s ease-in-out;
-webkit-transition: .2s ease-in-out;
}
It resolved all my problems, also i've edited the fiddle
http://jsfiddle.net/zakL5e8b/2/
Related
I've got a dropdown menu that uses lists to achieve it. The sub menu has a height of 0 and then the hight changes when the user hovers over it.
The limit of the animation is that I can't set the max-height as auto so I've set it to a value that it unlikley that the sub menu will ever reach.
Since the tranistion time is based on the max-height is is very fast so I've slowed it down to be a suitable speed but what I'd like is to have it disappear a lot faster when someone un-hovers or even have it disppear immediately. Is there a way to do this?
.menu ul ul{
float: left;
padding: 0;
position: absolute;
text-align: left;
width: 274px;
z-index: 1000;
max-height: 0;
overflow: hidden;
-webkit-transition: max-height 1s ease-in;
-moz-transition: max-height 1s ease-in;
-o-transition: max-height 1s ease-in;
-ms-transition: max-height 1s ease-in;
transition: max-height 1s ease-in;
}
.menu ul li:hover ul, .menu li.over ul {
max-height: 999px;
}
I'd like to stick to CSS but I'm willing to use JavaScript.
Try this :
For the basic class ( not the :hover ), just define the transition duration you want for when the list will disapear.
On hover, define a new transition duration ( the duration that the list will take to appear ).
Quick exemple here : http://codepen.io/AxelCardinaels/pen/wBQZbm
HTML :
<div class="text">Some texte</div>
CSS :
.text{
background:blue;
transition:all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
-ms-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
.text:hover{
background:red;
transition-duration:2s;
}
In my theme I have a portfolio item, an image. I want to ovveride the default slide in animation to fade in/out on hover animation.
When I hover on image, I have fade in animation with portfolio title text.
But when I move my cursor off the image, it immediately dissappears without fade out animation. How to correct that ?
My code for the animation is like below:
.image .image-extras {
width: 101%;
height: 100%;
position: absolute;
top: 0;
left: 0;
opacity: 0;
text-align: center;
transition: opacity .2s ease-in-out;
-moz-transition: opacity .2s ease-in-out;
-webkit-transition: opacity .2s ease-in-out;
}
.image:hover .image-extras {
opacity: 1;
border-bottom: 4px solid #e10707 !important;
transition: opacity .2s ease-in-out;
-moz-transition: opacity .2s ease-in-out;
-webkit-transition: opacity .2s ease-in-out;
When I change word "opacity" in above code to 'all' I get the both in/out animations but the fade is reversed to default slide in from the top from my custom theme and I do not want that.
I have the following CSS to control three a tags which should have vertically central text, however they appear at the top of the button. It's easier to see result.
CSS Code:
color: #fffae6;
border: 1px solid #fff;
outline: 4px solid #242424;
-moz-transition: background 500ms ease-in-out;
-ms-transition: background 500ms ease-in-out;
-o-transition: background 500ms ease-in-out;
transition: background 500ms ease-in-out;
padding: 5px 0;
-webkit-transition: background 500ms ease-in-out;
background: #242424;
font-size: 1.7em;
display: block;
margin: 0 15px;
In chrome:
In IE:
Any ideas?
you have to use both the height and line-height property to achieve the same effect in IE.
Check the DEMO.
Please use line-height, as per your height of the button. I hope it will work
So I'm currently trying to get my menu (which worked well before I added the sub-menus) to fade color when hovered. I can't really understand what the problem is but guessing that the webkit function (Again, which worked before and I haven't touched it) isn't really affecting the hover function.
Find code here:
jsfiddle.net/ChH4F
The transition you had was fine but without a hover state on your a tags there is nothing to change.
This is what I added,
ul#navmenu li a:hover {
color: rgba(0, 0, 0, 0.4);
}
This is what I changed since you don't need all,
-webkit-transition: color 0.7s ease;
-moz-transition: color 0.7s ease;
-o-transition: color 0.7s ease;
-ms-transition: color 0.7s ease;
transition: color 0.7s ease;
Here is the JSFIDDLE.
Revision 1 - fading sub-menu links of the same color
Revision 2 - fading sub-menu links of a different color
Drop-Down fading in without JS/jQuery,
ul#navmenu li ul.sub-menu {
position: absolute;
top: 40px;
left: 0;
width: 165px;
background-color:rgba(0, 13, 38, 0.9);
text-align:left;
color:black;
opacity: 0; /* Used to make it fade */
height: 0; /* Used to make it fade */
overflow: hidden; /* Used to make it fade */
}
ul#navmenu li:hover ul.sub-menu {
opacity: 1; /* Used to make it fade */
height: auto; /* Used to make it fade */
overflow: none; /* Used to make it fade */
}
Also don't forget to add the css-transitions to your main ul, ul.sub-menu.
Fade-in-out Menu
What you are forgetting to add,
ul#navmenu, ul#navmenu ul.sub-menu {
margin: 0px;
padding: 0;
padding-top:px;
list-style-type: none;
list-style-image: none;
width: auto;
height: auto;
transition: all 0.6s ease;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-ms-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
You need the transition: all 0.6s ease; on the element that is changing or it will just show/hide.
I am trying to do simple tooltip only with css3 and html, but the transition doesn't work. What am I doing wrong?
HTML
<p>
This has tooltip
</p>
<div class="tooltip">Tooltip content</div>
CSS
p {
width: 200px;
background-color: aqua;
padding: 10px;
margin-top: 50px;
}
div.tooltip {
position: absolute;
width: auto;
padding: 10px;
background-color: rgba(0,0,0, 0.5);
top: 0px;
display: none;
opacity: 0.0;
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
p:hover + div.tooltip {
display: block;
opacity: 1.0;
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
http://jsfiddle.net/MCDg4/
Update / Alternate solution
For a modern browser CSS3 solution you could use pseudo elements..
<span data-tooltip="I am the tooltip">This has a tooltip</span>
and
[data-tooltip]{
position:relative;
}
[data-tooltip]:before{
content:attr(data-tooltip);
position:absolute;
bottom:110%;
padding:10px;
background:#666;
opacity:0;
color:white;
font-size:smaller;
-webkit-transition:opacity 1s ease;
-o-transition:opacity 1s ease;
transition:opacity 1s ease;
pointer-events:none;
}
[data-tooltip]:hover:before{
opacity:1;
}
Demo at http://jsfiddle.net/BJ2tr/
(this could be done without pseudo-elements by nesting the tooltip inside the elements that it refers to, and adjusting the css accordingly)
Unfortunately when you change display from none to something else, you cannot have transitions.
Instead of display:none you could just offset it outside of the window (with top:-9999px) and bring it to position when showing it.
div.tooltip {
position: absolute;
width: auto;
padding: 10px;
background-color: rgba(0,0,0, 0.5);
top: -999px; /*CHANGED THIS AND REMOVED display:none*/
display: none;
opacity: 0.0;
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
p:hover + div.tooltip {
opacity: 1.0;
top: 0px; /*ADDED THIS AND REMOVED display:block*/
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
This will, however, not fade out (only in) since it moves it away on mouseout (so it actually does fade but you do not see it because it is outside the viewport)..
Explanation
You put transition only on opacity, while when changing to display:block; it is shown as a block with opacity:1; by default.
Solution
(JSFiddle)
Delete the display:none; and display:block on your tooltip element.