gpt4 book ai didi

html - 全高 div 不起作用

转载 作者:行者123 更新时间:2023-11-28 02:12:51 28 4
gpt4 key购买 nike

我对简单的 html/css 技巧有疑问。

我想创建左栏高度为 100% 的网站,例如宽度 300px,在右侧我想要 contener div 和其余的宽度。

下面的代码:

html {min-height:100%; position relative;}
body {margin:0px; height:100%;}
.left-bar {position:absolute; width:100px; background:#f8e8bc; top:0; bottom:0; left:0; right:0; overflow:hidden;}
.contener {float:right; right:0px; width: calc(100% - 100px); height:100%; background:#eee;}
.box {margin:auto; width:150px; height:500px; overflow:hidden; border:1px solid #ccc;}
<html>
<body>
<div class="left-bar"></div>
<div class="contener">
<div class="box"></div>
</div>
</body>
</html>

最佳答案

使用 position: fixed 而不是 absolute

关于html - 全高 div 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48649970/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com