2013-04-01 79 views
2

我尝试在悬停状态下实现带有额外填充的选项卡栏。 但问题是悬停状态实际上它移动父div。css选项卡栏高度问题

你可以看到下面的html;

<div id="statNav"> 
     <a href="#">Gogus</a> 
     <a href="#">Kol</a> 
     <a href="#">Gogus</a> 
     <a href="#">Gogus</a> 
     <a href="#">Gogus</a> 
     <a href="#">Omuz</a> 
     <a href="#">Gogus</a> 
</div> 

and css;

#statNav{ 
    width:100%; 
    border-bottom:2px solid #9B2F2C; 
    overflow:auto; 
} 

#statNav a{ 
    float:left; 
    background-color:#333333; 
    color:white; 
    font-size:12px; 
    font-weight:bold; 
    text-align:center; 
    width:62px; 
    padding-top: 5px; 
    padding-bottom:5px; 
    border-right: 1px solid #777777; 
} 

#statNav a:first-child{ 

    -webkit-border-radius: 5px 0px 0px 0px; 
    border-radius: 5px 0px 0px 0px; 
} 

#statNav a:last-child{ 

    -webkit-border-radius: 0px 5px 0px 0px; 
    border-radius: 0px 5px 0px 0px; 
    border-right:none; 
    width:63px; 
} 

#statNav a:hover{ 

    -webkit-border-radius: 5px 5px 0px 0px; 
    border-radius: 5px 5px 0px 0px; 
    background-color:#9B2F2C; 
    padding-top: 15px; 
} 

这是工作示例;

http://jsfiddle.net/Kg3p4/

我该怎么解决呢?

回答

0

您可以通过添加一个等于填充差异的负边距底部来修改悬停状态。事情是这样的:

#statNav a:hover{ 

    -webkit-border-radius: 5px 5px 0px 0px; 
    border-radius: 5px 5px 0px 0px; 
    background-color:#9B2F2C; 
    padding-top: 10px; 
    margin-bottom: -5px; 
} 

http://jsfiddle.net/Kg3p4/5/