Why does my CSS animation not work on my sidebar? - css

Good Day, I'm trying to create a slidedown menu using some JS and CSS but it's not working. Here's the fiddle link:
ul.show-child{
height: auto;
display: block;
-webkit-transition: height 1s ease;
-moz-transition: ease-in 2s none;
-ms-transition: ease-in 2s none;
-o-transition: ease-in 2s none;
transition: ease-in 2s none;
}
https://jsfiddle.net/gkrja9jy/
What I want to do, is to add some cool animation when I show the hidden div. By the way, I just copied the transition effect from this site

There is a pure CSS solution. I corrected your example. Make sure that you write correct HTML code. Here is the new code and a fiddle:
HTML code:
<ul class="custom-sidebar">
<li>
Accountancy
</li>
<li>
Grade School
<ul>
<li>Goals and Objectives</li>
<li>Clubs and Orgs</li>
<li>Photo Gallery</li>
<li>Summer Tutorial</li>
</ul>
</li>
</ul>
CSS code:
li ul {
display: block;
height: 0px;
overflow: hidden;
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;
-ms-transition: all 0.25s ease-in-out;
-o-transition: all 0.25s ease-in-out;
transition: all 0.25s ease-in-out;
}
li:hover ul {
height: 100px;
display: block;
}
.custom-sidebar a,.custom-sidebar a:visited {
color: #0f5882;
display: block;
font-weight: bold;
height: 25px;
margin-left: -23px;
padding-left: 23px;
vertical-align: middle;
width: 100% !important;
}
.custom-sidebar li {
list-style: outside none none;
padding-left: 17px;
}
.custom-sidebar li a {
background-color: #ebecec;
border-left: 6px solid #116b9e;
padding-top: 2px;
margin-bottom: 8px;
}
https://jsfiddle.net/u6yrL0a0/2/
It is usually best to avoid JavaScript if it is not needed.

yo can use jquery to create the animation like this:
var jq=jQuery.noConflict();
jq(document).ready(function(){
jq('.menu-div').hover(function(){
if(jq(this).children(":first").hasClass('has-child')){
var thisx = jq(this).children(":first");
thisx.next('ul').slideDown(1000);
}
});
});
jq(document).ready(function(){
jq('.menu-div').mouseleave(function(){
if(jq(this).children(":first").hasClass('has-child')){
var thisx = jq(this).children(":first");
thisx.next('ul').slideUp(1000);
}
});
});
and the css will be like this :
ul.hide-child{
display: none;
overflow: hidden;
}
ul li ul{
-webkit-transition: all 1s;
-moz-transition: all 1s ;
transition: all 1s;
display:none;
height:auto;
}
.custom-sidebar .post-link,.post-link:visited{
color: #0f5882;
display: block;
font-weight: bold;
height: 25px;
margin-left: 0px;
padding-left: 23px;
vertical-align: middle;
width: 100% !important;
}
.custom-sidebar li{
background-color: #ebecec;
border-left: 6px solid #116b9e;
list-style: outside none none;
margin-bottom: 0px;
padding-left: 17px;
padding-top: 2px;
}
https://jsfiddle.net/gkrja9jy/5/

Related

CSS selector error - Submenu not showing on Hover

Been battling with getting my Submenu to show on hover, it works but as soon as I slide off the parent element '.dropdown-toggle', the Submenu disappears.
Been trying for hours to fix this, look at the code below and see if you can solve the issue please.
Much appreciated
.dropdown-menu {
position: absolute;
top: 40px;
border: none;
padding: 0;
border-radius: 0;
width: 200px;
background: #e8e8e8;
visibility:hidden;
opacity:0;
filter:alpha(opacity=0);
-webkit-transition:700ms ease;
-moz-transition:700ms ease;
-o-transition:700ms ease;
transition:700ms ease;
}
.dropdown-toggle:hover + .dropdown-menu, .dropdown-menu {
display: block;
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}
Just a few changes can solve this:
dropdown-toggle changed to dropdown-menu.(Parent changed)
.dropdown-menu {
position: absolute;
top: 33px; /* reduced the gap so that it wont dissapear while hovering on submenu*/
border: none;
padding: 0;
border-radius: 0;
width: 200px;
background: #e8e8e8;
visibility:hidden;
opacity:0;
filter:alpha(opacity=0);
-webkit-transition:700ms ease;
-moz-transition:700ms ease;
-o-transition:700ms ease;
transition:700ms ease;
}
.dropdown:hover .dropdown-menu {
display: block;
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}
You may try this CSS:
.dropdown-menu {
position: absolute;
border: none;
padding: 0;
border-radius: 0;
width: 200px;
background: #e8e8e8;
visibility: hidden;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: 700ms ease;
-moz-transition: 700ms ease;
-o-transition: 700ms ease;
transition: 700ms ease;
margin-top: -5px;
padding-top: 5px;
}
.dropdown-toggle {
position: relative;
display: inline-block;
}
.dropdown-toggle:hover .dropdown-menu {
display: block;
visibility: visible;
opacity: 1;
filter: alpha(opacity=100);
}
HTML:
<div class="dropdown-toggle">
<a>Hover me</a>
<ul class="dropdown-menu">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</div>
Demo: http://jsfiddle.net/lotusgodkk/GCu2D/2204/
Thanks for your all your answers. This was the working solution below.
.dropdown-menu {
position: absolute;
top: 40px;
border: none;
padding: 0;
border-radius: 0;
width: 200px;
background: #e8e8e8;
visibility:hidden;
opacity:0;
filter:alpha(opacity=0);
-webkit-transition:700ms ease;
-moz-transition:700ms ease;
-o-transition:700ms ease;
transition:700ms ease;
}
.dropdown:hover .dropdown-menu, .dropdown-menu {
display: block;
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}

Negative text indent, translate on hover bug (firefox)

I'm experiencing a firefox specific bug with a simple menu I've built
It's a ul-list that has an on-hover effect for the list items, the list items have transform:translateX(12px) applied on hover, and the text links have a negative indent applied at all times, the combination of the two create a Firefox specific bug where part of the text disappears on hover during its animation, looks like its basically being hidden by its own padding because of the negative value.
Here is a JS Fiddle as well as the code, am I missing -moz- css?
https://jsfiddle.net/CultureInspired/9435v0vy/1/
<ul class="menu_desktop">
<li>Home</li>
<li>About</li>
<li>Press</li>
<li>Contact</li>
</ul>
CSS:
.menu_desktop {
list-style-type: none;
margin: 80px;
padding: 0;
}
.menu_desktop li {
background: #fff;
margin-bottom: 10px;
text-indent: -.8em;
text-transform: uppercase;
letter-spacing: 6px;
display: table;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-ms-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.menu_desktop li:hover {
transform: translateX(12px);
}
.menu_desktop a {
color: #000;
height: 100%;
padding: 8px;
display: block;
text-decoration:none;
}
I've got the same issue with firefox 49.0.2, it seems like a bug.
You can solve this by using margin-left: 12px; instead of the transform you are currently using.
Here is the fix (works in firefox, chrome & ie):
body {
background: lightgray;
}
.menu_desktop {
list-style-type: none;
margin: 80px;
padding: 0;
}
.menu_desktop li {
background: #fff;
margin-bottom: 10px;
text-indent: -.8em;
text-transform: uppercase;
letter-spacing: 6px;
display: table;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-ms-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.menu_desktop li:hover {
margin-left: 12px;
}
.menu_desktop a {
color: #000;
height: 100%;
padding: 8px;
display: block;
text-decoration:none;
}
<ul class="menu_desktop">
<li>Home</li>
<li>About</li>
<li>Press</li>
<li>Contact</li>
</ul>

How to make CSS3 transition working for border-bottom property which starts from bottom to top

I have 2 examples below which display 4 links and hovering upon them display border bottom with ease effect.
In the Example 1 the border-bottom display from top-bottom. I have tried revering with the padding property which is there in Example 2, Its not consistent across the browsers and it does not works properly.
Example 1: transition default functionality (transition from top-bottom)
<!DOCTYPE html><html class=''>
<head>
<style class="cp-pen-styles">
body {
padding: 50px;
}
a, a:hover {
text-decoration: none;
}
li {
position: relative;
padding-bottom: 3px;
margin-right: 10px;
display: inline;
}
li a {
border-bottom: 0em solid transperant;
color: #777;
}
li:focus > a,
li:hover > a,
li:active > a {
border-bottom: 0.313em solid #206E9F;
transition: border-bottom .2s ease-in-out;
-webkit-transition: border-bottom .2s ease-in-out;
-moz-transition: border-bottom .2s ease-in-out;
-ms-transition: border-bottom .2s ease-in-out;
}
|
</style>
</head>
<body>
<ul>
<li>HOME</li>
<li>PAGE</li>
<li>ABOUT US</li>
<li>CONTACT US</li>
</ul>
</body>
</html>
Example 2: transition from bottom-top (using padding - Compatibility issue with IE browser)
<!DOCTYPE html><html class=''>
<head>
<style class="cp-pen-styles">
body {
padding: 50px;
}
a, a:hover {
text-decoration: none;
}
li {
position: relative;
padding-bottom: 3px;
margin-right: 10px;
display: inline;
}
li a {
color: #777;
padding-bottom:0.4em;
border-bottom: 0em solid transperant;
}
li:focus > a,
li:hover > a,
li:active > a {
padding-bottom:0em;
border-bottom: 0.313em solid #206E9F;
transition: all .2s ease-in;
-webkit-transition: all .2s ease-in;
-moz-transition: all .2s ease-in;
-ms-transition: all .2s ease-in;
}
</style></head><body>
<ul>
<li>HOME</li>
<li>PAGE</li>
<li>ABOUT US</li>
<li>CONTACT US</li>
</ul>
</body></html>
How to make CSS3 transition working for border-bottom property which starts from bottom to top.
You can simulate your desired outcome by using :after or :before pseudo elements. This way you'll have much greater control over the desired effect (like adding various transforms).
body {
padding: 50px;
}
a {
text-decoration: none;
}
li {
display: inline;
margin-right: 10px;
}
li a {
border-bottom: 0 solid transparent;
color: #777;
display: inline-block;
padding-bottom: 3px;
position: relative;
}
li a > .fancy-line {
background-color: transparent;
content: "";
display: block;
height: 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
-o-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
-ms-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
-moz-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
-webkit-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
}
li a:hover > .fancy-line {
background-color: #206E9F;
height: 3px;
}
<ul>
<li>HOME <span class="fancy-line"></span></li>
<li>PAGE <span class="fancy-line"></span></li>
<li>ABOUT US <span class="fancy-line"></span></li>
<li>CONTACT US <span class="fancy-line"></span></li>
</ul>
You can do this with a pseudo-element and a transform rather than a border.
body {
padding: 50px;
}
a,
a:hover {
text-decoration: none;
}
li {
position: relative;
padding-bottom: 3px;
margin-right: 10px;
display: inline;
}
li a {
border-bottom: 0em solid transperant;
color: #777;
position: relative;
}
li > a::after,
li > a::after,
li > a::after {
content: '';
position: absolute;
width: 100%;
height: .313em;
background: #206E9F;
top: 100%;
left: 0;
transform-origin: center bottom;
transform: scaleY(0);
transition: transform .2s ease-in-out;
}
li:focus > a::after,
li:hover > a::after,
li:active > a::after {
transform: scaleY(1);
}
<ul>
<li>HOME
</li>
<li>PAGE
</li>
<li>ABOUT US
</li>
<li>CONTACT US
</li>
</ul>

CSS in IE8 not working

This is doing my head in, please can someone help? I have made a site, works in Ie9 + 10 and all other browsers, but the animated menu doesnt work in IE8 and there are people using that to view the site..
here is the css:
.menu, .menu ul, .menu li, .menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
.menu {
height: 40px;
width: 800px;
background: #f7d000;
background: -webkit-linear-gradient(top, #f7d000 0%,#f7d000 100%);
background: -moz-linear-gradient(top, #f7d000 0%,#f7d000100%);
background: -o-linear-gradient(top, #f7d000 0%,#f7d000 100%);
background: -ms-linear-gradient(top, #f7d000 0%,#f7d000 100%);
background: linear-gradient(top, #f7d000 0%,#f7d000 100%);
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
}
.menu li {
position: relative;
list-style: none;
float: left;
display: block;
height: 50px;
}
.menu li a {
display: block;
padding: 0 14px;
margin: 5px 0;
line-height: 28px;
text-decoration: none;
font-family: 'Titillium Web', sans-serif;
font-weight: bold;
font-size: 15px;
color: #000000;
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
.menu li:first-child a {
border-left: none;
}
.menu li:last-child a {
border-right: none;
}
.menu li:hover > a {
color: #ffffff;
}
.menu ul {
position: absolute;
top: 40px;
left: 0;
z-index: 999;
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
background: #f7d000;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
.menu li:hover > ul {
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
.menu ul li {
height: 0;
overflow: visible;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
.menu li:hover > ul li {
height: 36px;
overflow: visible;
padding: 0;
}
.menu ul li a {
width: 180px;
padding: 8px 10px;
margin: 0;
border: none;
border-bottom: 1px solid #f7d000;
}
.menu ul li:last-child a {
border: none;
}
The site is: www.softwaretestingawards.com any help would be appreciated!
IE8 does not support CSS3 animations.
See this reference:
http://caniuse.com/#search=css%20tran
You many want to consider using javascript animations, like jQuery.animate
http://api.jquery.com/animate/
The reason it won't work in Internet Explorer 8 is because it does not support CSS3 animations. I recommend you make a script to detect if Internet Explorer 8 is being used and, if it is, dynamically change the website so it doesn't have the fancy CSS3 animations.
to make work the css in IE8 you can try using PIE.htc, refere this site for solution and demos if you want http://css3pie.com/demos/, actually it worked for me :)

Pure CSS Drop-down Menu Not Displaying Properly in IE8

My pure css drop-down menu works in all major browsers except IE8. There are two issues.
1) The background color of menu doesn't display until the mouse rolls over one of the menu items. (see photo in link below)
http://www.searchtransparency.net/stackoverflow/2.jpg
2) If the menu is exited from the parent link (treatments) it leaves a shortened version of the background displaying. (see photo in link below)
http://www.searchtransparency.net/stackoverflow/1.PNG
CSS:
.menu,
.menu ul,
.menu li,
.menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
z-index:3;
}
.menu {
height: 53px;
width: 994px;
}
.menu li {
position: relative;
list-style: none;
float: left;
display: block;
height: 38px;
padding-top: 15px;
}
.menu li a {
display: block;
padding-left: 44px;
padding-right: 44px;
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
margin-top: 0px;
margin-right: 0;
margin-bottom: 0px;
margin-left: 0;
padding-top: 0;
padding-bottom: 0;
}
.menu li:first-child a { border-left: none; }
.menu li:last-child a{ border-right: none; }
.menu li:hover > a { color:#CCC; }
.menu ul {
position: absolute;
top: 53px;
left: 0;
opacity: 0;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
-webkit-box-shadow: 0px 0px 5px 0px #333;
box-shadow: 0px 0px 5px 0px #333;
background-color: #222;
padding-bottom: 15px;
visibility: hidden;
behavior: url(PIE.htc);
}
.menu li:hover > ul {
opacity: 1;
visibility: visible;
}
.menu ul li {
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
.menu li:hover > ul li {
height: 25px;
overflow: visible;
}
.menu ul li a {
width: 175px;
margin: 0;
font-size: 12px;
text-shadow: none;
border: none;
padding-left: 25px;
height: 20px;
padding-top: 5px;
}
.menu ul li:last-child a { border: none; }
.menu li li:hover > a {
background-color: #666;
}
HTML:
<ul class="menu">
<li><img src="images/icon-home.png" alt="Home" width="18" height="18" border="0"></li>
<li>Meet The Doctor</li>
<li class="icon-dropdown-arrow">Treatments
<ul>
<li style="font-size:14px; padding-left:15px; padding-top:10px; margin-top:10px;">Skin Resurfacing</li>
<li>Fraxel® Restore</li>
<li style="font-size:14px; padding-left:15px; padding-top:10px; margin-top:0px;">Skin Tightening</li>
<li>Thermage®</li>
<li>Refirme® Photo-Rejuvenation</li>
<li style="font-size:14px; padding-left:15px; padding-top:10px; margin-top:0px;">Cellulite Treatments</li>
<li>LPG Lipomassage™</li>
<li>VelaShape™</li>
<li>Thermage®</li>
<li>Ionithermie Treatment</li>
<li style="font-size:14px; padding-left:15px; padding-top:10px; margin-top:0px;">Injectibles</li>
<li>Dermal Fillers</li>
<li>Botox® Cosmetic</li>
<li style="font-size:14px; padding-left:15px; padding-top:10px; margin-top:0px;">Other</li>
<li>Laser Hair Removal</li>
<li>Skin Treatments (Face & Body)</li>
<li>Skin Rejuvenation</li>
<li>Plastic Surgery</li>
<li>Massage</li>
</ul>
</li>
<li>Specials</li>
<li>Reviews</li>
<li>Contact</li>
</ul>
Code on JsFiddle.net
As i remember IE understand :hover only just for "a" tag.
:last-child doesn't support too, question about :last-child

Resources