Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS menu hover not working

Tags:

css

I want to build a menu where every single <li> hovers out. But weirdly the whole menu always hovers out. Here is the fiddle code.

I have the following css code:

body {
background-color: #eee;
margin: 0;
padding: 0;
overflow: hidden;
}

.tabs {
    width: 80%;
    position: fixed;
    bottom: -20px;
    left: 100px;
}
.tabs ul {
    display:block;
}
.tabs li {
    width: 60px;
    height: 80px;
    margin-bottom: -20px;
    padding: 10px;
    float: left;
    list-style: none;
    display: inline;
    background-color: #ccc;
    -moz-border-radius-topleft: 10px;
    -moz-border-radius-topright: 10px;
    -moz-border-radius-bottomright: 0px;
    -moz-border-radius-bottomleft: 0px;
    -webkit-border-radius: 10px 10px 0px 0px;
    border-radius: 10px 10px 0px 0px;
    font-family: verdana;
    text-align: center;
}
.tabs li:hover {
    margin-bottom: 20px;
}​
like image 638
Philipp Braun Avatar asked Mar 25 '26 18:03

Philipp Braun


2 Answers

Reason is that when you give margin to it then it's push whole ul. It's better give bottom instead of margin. write like this:

.tabs li:hover {
    bottom: 20px;
}

Check this http://jsfiddle.net/X96KE/17/

like image 83
sandeep Avatar answered Mar 27 '26 07:03

sandeep


using jQuery will solve your problem if you are familiar with it try this

  jQuery("li").mouseover(function() {
    jQuery(this).css("margin-bottom","20px");
  }).mouseout(function(){
   jQuery(this).css("margin-bottom","0px");
  });
like image 43
Rizstien Avatar answered Mar 27 '26 08:03

Rizstien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!