我正在尝试执行以下操作:点击PORTFOLIO
http://jsfiddle.net/kuuwj/25/,您可以看到当您点击投资组合按钮子菜单时。但是我改变了颜色,所以你可以看到问题。问题是下一个按钮ABOUT ME
将展开以保持相同的边距,并且它将与portfolio-apps
类重叠。所以我想解决这个问题。通过这种方式,about me
将具有相同的边距,但来自section
的最后一个portfolio-apps
#navbar {
list-style: none;
z-index: 9;
width: 255px;
display: block;
margin-top: 20px;
margin-bottom: 20px;
background: #ccc;
}
#navbar a {
text-decoration: none; /* removes underline for links */
text-transform: uppercase;
font-size: 16px;
display: block;
background: #fff; /* for webbrowsers that does not support CSS3 */
background: rgba(255,255,255,0.9);
line-height: 50px; /* specifies the line height */
padding: 0px 20px;
color: rgb(68,68,68);
}
#navbar a:hover { /* Select a style of a link when the mouse over it */
background: #bbb;
}
#navbar li {
margin-bottom: 6px;
}
.button {
position: relative;
display: block;
float: left;
line-height: 35px;
left: 75px;
padding-right: 10px;
text-align: right;
font-size: 16px;
}
span {
background: #EEE;
}
<ul id="navbar">
<li><a href="#home" id="nav-home">Home</a></li>
<li><a href="#portfolio" id="nav-portfolio">Portfolio</a>
<div class="portfolio-apps">
<section id="website">
<span class="button">AAAAAAAAAAAAAAAAAAAAAA</span>
</section>
<section id="gterminal">
<span class="button">BBBBBBBBBBBBBBBBBBBBBB</span>
</section>
<section>
<span class="button">CCCCCCCCCCCCCCCCCCCCCC</span>
</section>
</div>
</li>
<li><a href="#about" id="nav-about">About Me</a></li>
<li><a href="#contact" id="nav-contact">Contact</a></li>
</ul>
答案 0 :(得分:1)
你必须清除你的花车 - DEMO
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}