gpt4 book ai didi

html - 停止 div 延伸到父级下方

转载 作者:太空宇宙 更新时间:2023-11-03 17:44:34 24 4
gpt4 key购买 nike

我在一个 div 中有一个 div,但是第二个 div 并没有从父 div 的顶部开始,它被一个标题分流了。第二个 div 包含很多东西并且需要滚动,所以我将它设置为 100% 高度并允许溢出;但是,因为它不是从父 div 的顶部开始,所以它延伸到父 div 的底部。

这是一个代码片段

html, body {
height: 100%;
overflow:hidden;
margin:0;padding:0
}

.profile-box {width: 46.6%; /*max-width: 560px;*/ height: 35%; max-height:600px; background-color:white; margin:1.6%; padding-top: 0.8%; padding-left: 0.8%; padding-right: 0.8%;}
.profile-form {margin-right:5; margin-left:auto; padding-right:3%;}
.profile-slider {width:45%}
.profile-slider-label {margin-right:1%}

.left-align {float:left;}
.right-align {float:right;}
.y-scolling {overflow-y:auto; overflow-x:hidden; height:100%;}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="profile-box right-align" style="background-color:red">
<h2>Lifestyle</h2>
<p class="left-align">Scroll for more</p>

<div class="form-horizontal" style="background-color:grey">
<div class="y-scolling" style="background-color:yellow">
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div><div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>
<div class="form-group profile-form">
<input runat="server" class="profile-slider right-align" type="range" min="1" max="10" step="1" id="cat1" />
<label class="control-label right-align profile-slider-label" for="cat1">Cat1</label>
</div>

<!-- more of these -->
</div>
</div>
</div>
</body>

As you can see, the same height as its container, but just offset.

More colours in the divs

最佳答案

尝试添加 overflow: scroll;到那个 div 的 css。

例子:

div.someClass { 
overflow: scroll;
}

您也可以尝试其他溢出属性。但是从图片上看,您希望它在 div 中滚动。溢出:隐藏也可能是一个选项。

关于html - 停止 div 延伸到父级下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28483108/

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