2017-10-28 128 views
0

如何告诉div使用标有红色箭头的整个区域,而不管浏览器的大小和div内容如何?如何扩展div以使用所有可能的区域

enter image description here

我想:<div style='height:100%;width:'100%'>...</div>但是只需要水平面积,而不是垂直的。有没有办法做到这一点?

+0

的语法应该是''

...
。 (冒号,不是=符号) – Laura

+0

@Laura反正它不起作用 – assembler

回答

1

看看这个小提琴 https://jsfiddle.net/o7u9hxou/

html 
<body> 
<div id="sidebar"></div> 
<div id="wrapper"> 
    <div id="topbar"></div> 
    <div id="else"></div> 
</div> 
</body> 

css 
body { 
    box-sizing: border-box; 
    height: 100vh; 
    margin: 0px; 
    padding: 0px; 
} 
#else { 
    background-color: green; 
    height: 90vh; 
} 
#sidebar { 
    background-color: pink; 
    display: inline-block; 
    float: left; 
    height: 100%; 
    min-width: 50px; 
    width: 10%; 
} 
#topbar { 
    background-color: yellow; 
    height: 10vh; 
    min-height: 20px; 
} 
#wrapper { 
    display: inline-block; 
    float: right; 
    height: 100%; 
    width: 90%; 
}