我正在开发这个website,我希望正确的侧边栏有100%的高度。
body {
height: 100%;
min-height: 100%;
position: relative;
}
mydiv {
height: 100%;
min-height: 100%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 290px;
}
我已经读了很多答案,特别是这个(Prestaul答案):Setting 100% height on an absolutely positioned element when the content expands past the window size。
但对我来说,这个技巧不起作用,小提琴的例子也不起作用!
发布于 2013-01-31 23:13:58
尝试将正文样式设置为:
body { position:relative;}
这对我很管用
发布于 2013-01-31 23:07:30
也要设置html标记。这样就不需要奇怪的位置技巧了。
html, body {height: 100%}
发布于 2017-11-14 06:47:11
CSS Flexbox旨在简化这些类型的布局的创建。
html {
height: 100%;
}
body {
height: 100%;
display: flex;
}
.Content {
flex-grow: 1;
}
.Sidebar {
width: 290px;
flex-shrink: 0;
}
<div class="Content" style="background:#bed">Content</div>
<div class="Sidebar" style="background:#8cc">Sidebar</div>
https://stackoverflow.com/questions/14628838
复制相似问题