Ana*_*man 29 html css height responsive-design twitter-bootstrap
我在twitter-bootstrap中有一个div元素,其内容将在屏幕外垂直溢出.
我希望div取出浏览器窗口大小的高度,让其余内容在窗口中垂直滚动.
我有一个不能正常工作的样本@ jsFiddle
#content {
border: 1px solid #000;
overflow-y:auto;
height:100%;
}
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">Side Bar</div>
<div class="span9" id="content">
Content Bar Example Content
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
编辑 -
对不起伙计我想我的问题出错了.
我想要的是我的div必须填满屏幕中其余的垂直空间.
如果有人可以建议一个响应式解决方案,那就太好了
Kur*_*den 59
使用CSS {height: 100%;}
匹配父级的高度.这可能是任何东西,意味着比屏幕更小或更大.使用{height: 100vh;}
匹配视口的高度.
.container {
height: 100vh;
overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)
根据Mozilla的官方文件,1vh是:
等于视口初始包含块高度的1%.
Pra*_*man 26
你也需要给height
父元素!看看这个小提琴.
html, body {height: 100%;}
#content, .container-fluid, .span9
{
border: 1px solid #000;
overflow-y:auto;
height:100%;
}?
Run Code Online (Sandbox Code Playgroud)
$(document).ready(function(){
$(window).resize(function(){
$(".fullheight").height($(document).height());
});
});
Run Code Online (Sandbox Code Playgroud)
gau*_*171 13
试试这个
$(document).ready(function(){
$('#content').height($(window).height());
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
122809 次 |
最近记录: |