I tried a lot and already searched in Google but I don't find a solution for my problem:
I made a jsfiddle for you to see my source-code: Click here for my Source Code
Everything works fine. But the transition doesn't work in Firefox.
Here is my Sourcecode because I have to post it too if I want to use a jsfiddle!
<nav>
<ul>
<li>Startseite</li>
<li>Projekte
<ul>
<li>Java / Bukkit</li>
<li>Webdesign</li>
<li>PHP | MySQL</li>
</ul>
</li>
<li>Kontakt</li>
<li>Über mich</li>
</ul>
<div class="clear"></div>
</nav>
// CSS down \\ HTML up
nav{
background: #333;
color: #fff;
padding: 5px;
}
nav ul{
padding: 0px;
margin: 0px;
list-style: none;
}
nav ul li{
float:left;
}
nav ul li a{
color: #fff;
background: #585858;
padding: 10px;
margin-right: 5px;
display: block;
text-decoration: none;
border: 1px solid white;
}
nav ul li a.active{
background: #373737;
}
nav ul li a:hover{
color: #333;
background: #fff;
border: 1px solid black;
}
nav ul li ul{
position: absolute;
height: 0px;
overflow: hidden;
}
nav ul li ul li{
float: none;
}
nav ul li:hover ul{
overflow: visible;
}
nav ul li:hover ul li a{
padding: 10px;
}
nav ul li ul li a{
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
-ms-transition: 0.3s;
-o-transition: 0.3s;
transition: 0.3s;
padding: 0px 10px;
}
It looks like removing the overflow:hidden from the container suddenly makes the transition work. This leads me to believe it's an "optimisation" in Firefox that doesn't compute the "hidden" element.
Personally, I've used this to produce a similar effect: Rather than hiding the element, give it transform:scaleY(0); normally, and transform:scaleY(1); on hover.
Related
I have a menu and some of my links have dropdown menus. Hovering over the link brings down the dropdown menu, but if I move my cursor onto the actual dropdown menu, the dropdown menu disappears.
Please help!
Here is the CSS and HTML of the actual menu:
CSS:
.menu ul {
color: #3d3d3d;
text-align: right;
float: right;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
.menu ul li {
font-family: LemonMilk;
font-size: 24px;
font-weight: bold;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.menu ul li:hover {
color: #0096ff;
}
.menu ul li ul {
padding: 0;
position: absolute;
background-color: rgba(0,0,0, 0.5);
margin-top: 5px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
.menu ul li ul li {
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
font-size: 16px;
}
.menu ul li ul li:hover { background-color: rgba(0,0,0, 0.9); }
.menu ul li:hover ul {
color: #0096ff;
display: block;
opacity: 1;
visibility: visible;
text-decoration: none;
}
.menu ul li a {
color: #3d3d3d;
}
.menu ul li a:hover {
color: #0096ff;
}
.menu ul li ul li a {
color: #fff;
}
.menu ul li ul li a:hover {
color: #0096ff;
}
HTML:
<header>
<div class="wrapper">
<div id="clogo"></div>
<span class="menu">
<ul id="dropnav">
<li><a href="/forums/index.php" />Forums</a></li>
<li>Members
<ul>
<li>Member List</li>
<li>Staff List</li>
</ul>
</li>
<li>Donate<br>
<ul>
<li>Buycraft</li>
<li>Buy Credits</li>
<li>CL Plus</li>
</ul>
</li>
</ul>
</span>
</div>
</header>
Consider to use > selector in the CSS, so it only looks one level down the markup structure, no deeper. A demo that made similar to your style - http://jsfiddle.net/55nw4wmy/
.class ul li {
affects all levels of <li> inside.
}
.class > ul > li {
only affects the first level.
}
.class > ul > li > ul > li {
only affects the second level.
}
That way, you don't have to overwrite the rules continually. And for the drop down disappearing problem, see the comments in the demo link above.
The codes you shown work fine on my end, but from your code I suspect .menu ul li ul { margin-top: 5px; } could be the cause of such behavior. Currently it's working only because the first-level li have a bottom padding that is larger than 5px.
If by any chance the li in your homepage header doesn't have a bottom padding, then the top margin in the 2nd level ul will cause a 5px space between the li and the ul sublist inside it. When you move your mouse from the li to the sub list the mouse passes through that 5px space zone which doesn't belong to the list item and :hover loses its effect.
I would suggest changing that to .menu ul li ul { padding-top: 5px; }
I have created a menu and i am trying to implement a drop down menu on hover, It doesn't seem to appear correct,any help would be appreciated. Why is the drop down appearing in different position ?
<ul class="menu">
<li>Home
<ul class="menu">
<li>Home</li></ul>
</li> |
<li class="active">About</li> |
<li>Products</li> |
<li>Clients</li> |
<li>Reach Us</li>
<div class="clear"></div>
</ul>
.menu{
float:left;
color: #555555;
margin-top: 25px;
}
.menu ul {}
.menu li{
display: inline-block;
margin:6px 20px;
}
.menu li a{
display: block;
color: #000;
line-height: 1.8em;
text-transform: capitalize;
font-size: 14px;
font-weight: 400;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
padding: 5px;
}
.menu li:hover > ul {
display: block;
}
.menu li.active a{
color: #52ABDF;
background: white;
}
.menu li a:hover{
color: #ooo;
background: #52ABDF;
padding: 5px;
}
.menu li ul{
display: none;
}
.menu ul li:hover ul{
display: block;
margin-left:0px;
}
.menu li ul li {
float: none;
display: inline;
}
.menu li ul li a {
position: relative;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
background: #333;
color: #ooo;
}
.menuli ul li a:hover {
background: #066;
color: #000;
}
Here is the code pen : http://codepen.io/anon/pen/EtmAB
As a tip,
you should never use '|' symbol to seperate the <li>s, because it
makes the html meaningless. The <ul> tag is expected to have only
<li> tags as its children.. You could use the border-right property instead. and use
ul li:last-of-type(){
border: 0;
}
to eliminate the border on the last <li>
Use this css and yours would work:
.menu,
.menu li ul{
float:left;
color: #555555;
margin-top: 0;
list-style: none;
padding: 0;
}
.menu{
margin-top: 25px;
}
.menu ul:after{
content: "";
display: block;
clear: both;
}
.menu li{
float: left;
position: relative;
}
.menu li a{
display: block;
color: #000;
line-height: 2em;
text-transform: capitalize;
font-size: 14px;
font-weight: 400;
padding: 0 20px;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.menu li:hover > ul {
display: block;
}
.menu li.active a{
color: #52ABDF;
background: white;
}
.menu li a:hover{
color: #ooo;
background: #52ABDF;
}
.menu li ul{
display: none;
position: absolute;
background: #bbb;
}
.menu li ul li {
display: inline ;
}
.menu li ul li a {
position: relative;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
background: #333;
color: #ooo;
}
.menuli ul li a:hover {
background: #066;
color: #000;
}
If you want to really learn how to make a better styled dropdown menu, use this tutorial:
http://andornagy.com/css-dropdown-menu/
it is pretty easy and understandable too, and not bad looking...
I've got a menu made that utilizes left and right borders to separate each menu item. When hovering over the menu, the background changes to a lighter shade, which is what I want. However, hovering also covers the left border. How can I stop the border from disappearing? I'm sure this has been answered elsewhere, but I couldn't find it. Thanks, in advance.
http://jsfiddle.net/aYsKp/2/
HTML:
<div id="header">
<div id="menu">
<ul>
<li>HOME
</li>
<li>PRODUCTS
</li>
<li>VIDEOS
</li>
<li>DOWNLOADS
</li>
<li>CONTACT
</li>
<li>ABOUT
</li>
</ul>
</div>
</div>
CSS:
#header {
width:960px;
margin: 10px auto 5px auto;
background-color: #727272;
}
#menu {
max-width:828px;
bottom:0;
right:0;
font: 12px/18px sans-serif;
}
#menu a {
text-decoration: none;
display:block;
padding: 10px 32px;
color:#FFF;
}
#menu ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
#menu ul li {
display: inline-block;
margin-right: -4px;
position: relative;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
border-right: 1px solid #FFF;
}
#menu ul li:first-child {
border-left: 1px solid #FFF;
}
#menu ul li:hover {
background-color:#818181;
}
Try this approach.
#header {
width:960px;
margin: 10px auto 5px auto;
}
#menu {
max-width:828px;
bottom:0;
right:0;
font: 12px/18px sans-serif;
background-color: white;
}
#menu a {
text-decoration: none;
display:block;
padding: 10px 32px;
color:#FFF;
}
#menu ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
#menu ul li {
display: inline-block;
position: relative;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
background-color: #727272;
margin:0;
}
#menu ul li:hover {
background-color:#818181;
}
What I've done is just removed right margin and specified background color as white for the menu div.
I use to set border or space informations in A tag, not in LI, making LI like an "invisible" tag, setting all properties to A, using A display:inline-block.
When I hover over my first navigation link the sublists don't line up vertically underneath each other but are beside each other instead. How do I get them to be the same width as the top navigation display vertically when hovered over?
My HTML:
<nav>
<ul>
<li>
fashion
<ul>
<li>street style</li>
<li>celebrity style</li>
</ul>
</li>
<li>beauty</li>
<li>music</li>
<li>entertainment</li>
</ul>
</nav>
My CSS:
nav {
font-family: 'Josefin Sans', sans-serif;
}
nav li {
display:block;
width: 25%;
background-color: #000;
position:relative;
float:left;
list-style:none;
}
nav a {
text-decoration: none;
font-size: 17px;
color: white;
padding:6pt 0;
text-align: center;
display: block;
border-bottom: 3px white solid;
text-transform:uppercase;
}
nav a:hover{
background: #d04576;
border-bottom: 3px white solid;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
nav ul li ul {
display:none;
width:100%;
}
nav li:hover ul {
display: block;
width:100%;
}
You are floating all of your li left.
Setting your nav li li to float: none; should do the trick. Try adding this to your css:
nav li li{
float: none;
}
Edit: Here is a jsFiddle: http://jsfiddle.net/TscH5/3/
I added comments at the top to explain the few things I fixed.
The problem is that when i hover on the area where the more link is, the menu appears and it should appear only if i have hovered over the More link, not on the area. I tried with overflow:hidden on the sub-menu .ktmsg ul li ul { but doesn't work.
I have the below code
HTML
<div class="ktmsg">
<li><a id="a0" href="#"> 0 </a></li>
<ul>
<li class="a1"> 1 </li>
<li>
More
<ul>
<li class="a4"> 4 </li>
<li class="a5"> 5 </li>
<li class="a6"> 6 </li>
</ul>
</li>
</ul>
</div>
CSS
.ktmsg {
font-size: 16px;
font-weight: normal;
margin: 0px;
height: 18px;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
width: 930px;
padding: 0px;
text-align: left;
height: 20px;
position: relative;
font-weight: normal;
font-size: 15px;
background-color: red;
}
.ktmsg a{
text-align: center;
padding: 13px 4px;
white-space: nowrap;
float: left;
text-decoration: none;
background:red;
color: #FFF;
min-width: 150px;
transition: all 0.4s;
}
.ktmsg ul{
list-style: none outside none;
width: 100%;
position: relative;
padding-left:0px;
}
.ktmsg li {
float:left;
position:relative;
list-style-type: none;
display: inline;
padding: 0px;
margin: 0px 10px;
background-image: none;
}
.ktmsg li a, .ktmenu li a:active, .ktmenu li a:visited {
margin:0px;
color: #FFF;
border: 0px;
text-decoration: none;
font-weight: bold;
}
.ktmsg ul li a:hover {
color: blue;
text-decoration: none;
}
.ktmsg a, .ktmsg a:active, .ktmsg a:visited {
color: #FFF;
margin:0px;
padding: 0px;
text-decoration: none;
}
.ktmsg ul li ul {
overflow:hidden;
padding:0;
background:red;
opacity:0;
height:auto;
width:auto;
margin-top:25px;
position:absolute;
transition-property: opacity;
box-shadow: 0 0 2px 2px;
border-radius: 6px;
transition-duration: 1s;
transition-timing-function: linear;
transition-timing-function: ease-out;
}
.ktmsg ul li:hover ul{
overflow:visible;
display:block;
background:red;
height:auto;
width:auto;
margin-top:25px;
opacity: 1;
box-shadow: 0 0 2px 2px;
border-radius: 6px;
}
.ktmsg ul li ul li{
background:red;
padding: 10px;
border-bottom: 1px solid rgb(51, 51, 51);
}
Fiddle-DEMO
This is because min-width of .ktmsg a is set to 150px. I suggest you to move it to .ktmsg li and it should solve problem you are mentioned.
As well you have to change .ktmsg ul a:hover + ul this is selector what should be instead to .ktmsg ul li:hover ul. And as well .ktmsg a shouldn't have float: left and paddings.
To ul doesn't disappear you have to add one other selector:
.ktmsg ul a + ul:hover,
.ktmsg ul a:hover + ul {
overflow:visible;
display:block;
opacity: 1;
/* rest of style */
}
I think it is working as you want it to, it's just that you have a min-width of 150px applied to your a links which is making the more link wider than you think it is.
.ktmsg ul li ul {
overflow: hidden !important;
}
Remove min-width: 150px; from style