目录隐藏其他元素

时间:2015-12-07 21:26:53

标签: html css

HTML:

<div class="menu-panel">
    <h3>Table of Contents</h3>
        <ul id="menu-toc" class="menu-toc">
            <li><a href="landingpage.html">Home</a></li>
            <li style="border-top: #FFF solid 1px;" class="menu-toc-current"><a href="index.html">Biography</a></li>
            <li><a href="extra_curricula.html">Extra Curricular</a></li>
            <li><a href="favorites.html">Favorites</a></li>
        </ul>
</div>
<div class="main">
    <h2>Biography</h2>    
    <p>THIS INFO SHOWS UP WITH HEAVY CSS EDITING</p>    
</div>

CSS:

.menu-panel {
    background: #013E7D;
    width: 240px;
    height: 100%;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
    margin: 0px;
}



.menu-panel h3 {
    font-family:Roboto;
    font-size: 1.8em;
    padding: 20px;
    font-weight: 300;
    color: #fff;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.05);
} 

.menu-toc {
    list-style: none;
}

.menu-toc li a {
       font-family:Roboto;
       display: block;
       color: #C0C0C0;
       font-size: 1.1em;
       line-height: 3.5;
       padding: 0 20px;
       cursor: pointer;
       background: #013E7D;
       border-bottom: 1px solid #FFF;
}

.menu-toc li a:hover,
.menu-toc li.menu-toc-current a {
    background: #000000;
}

.menu-panel div {
    margin-top: 20px;
}

.menu-panel div a {
    text-transform: uppercase;
    font-size: 0.7em;
    line-height: 1;
    padding: 5px 20px;
    display: block;
    border: none;
    color: #bc0b0b;
    letter-spacing: 1px;
    font-weight: 800;
    text-shadow: 0 1px rgba(255,255,255,0.2);
} 


@media screen and (max-width: 800px) {
    .no-js .menu-panel {
      display: none;
    }

    .no-js .container {
        padding: 0;
    }


@media screen and (max-width: 400px) {
    .menu-panel,
    .content {
         font-size: 75%;
    }

    .main {
         margin-left:797px;
         position:fixed;
         font-family:Roboto;
    } 

所以基本上我需要将目录设置为静态,以便所有其他元素绕过它!我一直试图解决这个问题,但它不起作用。如果你能帮助我,那将会有很大帮助!谢谢

1 个答案:

答案 0 :(得分:0)

.menu-panel {
  background: #013E7D;
  width: 240px;
  height: 100%;
  z-index: 1000;
  top: 0;
  left: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  margin: 0px;
  float: left;
}

在css中删除位置并添加浮点结果是水平对齐的块。另见http://codepen.io/anon/pen/XXJRWx