div之间的额外空间,另一个

时间:2012-11-08 22:41:18

标签: css3 positioning

不确定为什么我的div之间会有额外的空间

http://jsfiddle.net/3cx8w/1/

地狱很简单:

HTML:

<div id='menu'>
  <div id='menu-homepage'><a href='/?category=homepage'>Homepage</a></div>
  <div id='menu-prices'><a href='/?category=prices'>Prices</a></div>
  <div id='menu-contacts'><a href='/?category=contacts'>Contacts</a></div>
</div>

CSS:

#menu {
    position: absolute;
    top: 16%;
    left: 5%;
    width: 90%;
    background-color: #343434;
    border: 1px solid black;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

#menu div {
    display: inline-block;
    height: 100%;
    padding: 1% 2%;
    margin: 0;
    border-left: 1px dotted gray;
    border-right: 1px dotted gray;
    font-size: 60%;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
}

#menu a {
    color: white;
    text-decoration: none;
}

请帮忙。

1 个答案:

答案 0 :(得分:1)

给按钮划分样式

float:left;

而不是

display:inline-block;

并将此div添加到#menu

的末尾
<div style="clear:both"></div>