如何使div 100%的高度

时间:2014-09-21 16:04:00

标签: html css height

大家好,首先很抱歉提出已经被问过很多次的问题。请原谅我说我无法找到匹配并与我的代码一起使用的答案,这就是我要问的原因:)

嗯,我想让我的侧边栏div 100%高度而不只是调整到div里面的内容我该怎么做?

这是我的代码:

html, body {
    margin: 0px;
    height:100%;
    min-height:100%;
}

.SideMenu {
    height:100%;
    float:left;
    background-color:#ACB9B1;
    width:20%;
    margin:0;
    overflow-y:hidden;  
    overflow-x:hidden;  
}

http://jsfiddle.net/u9r7zeyk/这里显示的是全高,不知道为什么?

3 个答案:

答案 0 :(得分:0)

试试这个:

html, body {
    height:100%;
}

.SideMenu {
    height:100%;
    background-color:#ACB9B1;
    width:20%;
}

答案 1 :(得分:0)

编辑,你走了。我想这就是你想要的。

html, body {
        margin: 0px;

    }

    .SideMenu {
        position:absolute;
        height:100%;
        float:left;
        background-color:#ACB9B1;
        width:20%;
        margin:0;
        overflow-y:hidden;  
        overflow-x:hidden;  
    }

http://jsfiddle.net/u9r7zeyk/2/

答案 2 :(得分:0)

您好,感谢您输入的内容,您可以在此处看到:

.menu{
background-color:#ACB9B1;
width: 200px;
position: fixed;
top: 0px;
left: 0px;
bottom: 0px;    
}   

.menu li a {
display:block;
text-decoration: none;
color: #fff;
line-height: 1.5;
margin-left:5%;
color:#A92432;
           }
.menu li {
width: 100%;

height: 30px;
font-family: 'Open Sans';
border-bottom: 1px solid #A92432;;
font-size:18px;
         }
相关问题