0

好的,我在 CSS 上遇到了这个小问题。我有一个高度为 100% 的菜单 div,需要使用以下内容才能使其工作

#menu {
  background:#222;
  width:120px !important;
  float:left;
  position: absolute;
  top: 30px;
  bottom: 0px;
}

在我的内容区我有这个CSS

#content {
  float:left;
  display:block;
  height:300px !important;
  background:#333;
  width:100%;
}

在这里演示:jsFiddle - P3Adk

正如您将看到的内容在我不想要的菜单下。我希望它位于向左冲洗的菜单旁边。

4

3 回答 3

2

您是否尝试过类似以下的方法:

#content{
    display:block; 
    height:300px !important; 
    background:#333; 
    width:100%;
    margin:30px 0 0 120px;
}
#menu{
    background:#222;
    width:120px !important;
    float:left;
    position: absolute; 
    top: 30px; 
    bottom: 0px;
}​
于 2012-09-21T07:11:08.243 回答
0

这样

只需从菜单 div 中删除 position:absolute,给内容 div 一个百分比宽度,给菜单 div 一个百分比宽度(或固定像素宽度)和一个高度。

于 2012-09-21T00:58:17.740 回答
0

试试这个:

#content {  
    height:300px; 
    width:100%; 
    background:#333; 
}
.content-inner {
    position:relative; 
    margin-left: 130px; 
    border:1px solid #F00; 
}
#menu { 
    float: left; 
    z-index: 1; 
    position: absolute; 
    left:0; 
    top:30px; 
    bottom:0; 
    width:120px; 
    background:#222; 
}

http://jsfiddle.net/kpjqz/

于 2012-09-21T06:43:59.423 回答