gpt4 book ai didi

html - 使无序列表可滚动

转载 作者:搜寻专家 更新时间:2023-10-31 22:06:05 25 4
gpt4 key购买 nike

我有一个无序列表,它位于一个 div 标签内,最初该列表是空的。当元素被添加到它时,它会扩展并且我希望它在列表的长度超过网页的长度时可以滚动,即我不希望网页滚动,我只想要无序的列表滚动。但是目前,我的无序列表的滚动条没有出现。

我的 html 代码是:

<div style="width: 25%; float: right; " class="online_users">
<div class="panel panel-primary">
<div class="panel-heading">
<span class="glyphicon glyphicon-comment"></span> Online Users
<ul id="ListOfOnlineUsers" style="overflow: auto;height:100%; word-wrap: break-word;" class="list-group">
</ul>
</div>
</div>
</div>

我的 CSS 代码是

html{
height: 100%
}

{
margin: 0;
padding: 0;
}
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
height: 100%;

}

a {
color: #00B7FF;
}

.chat
{
list-style: none;
margin: 0;
padding: 0;
}

.chat li
{
margin-bottom: 10px;
padding-bottom: 5px;
border-bottom: 1px dotted #B3A9A9;
}

.chat li.left .chat-body
{
/*margin-left: 60px;*/
}

.chat li.right .chat-body
{
/*()margin-right: 60px;*/
}


.chat li .chat-body p
{
margin: 0;
color: #777777;
word-wrap: break-word;
}

.panel .slidedown .glyphicon, .chat .glyphicon
{
/*margin-right: 5px;*/
}

.panel-body
{
overflow-y: scroll;
top: 1em;
left: 1em;
height: 250px;
}

::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #F5F5F5;
}

::-webkit-scrollbar
{
width: 12px;
background-color: #F5F5F5;
}

::-webkit-scrollbar-thumb
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #555;
}


/* CSS used here will be applied after bootstrap.css */
body, html {
height: 100%;
background-repeat: no-repeat;
background-image: linear-gradient(rgb(154, 145, 162), rgb(12, 97, 33));
}

.card-container.card {
width: 350px;
padding: 40px 40px;
}
.card {
background-color: #F7F7F7;
/* just in case there no content*/
padding: 20px 25px 30px;
margin: 0 auto 25px;
margin-top: 50px;
/* shadows and rounded borders */
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
}
.btn {
font-weight: 700;
height: 36px;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: default;
}

.form-signin input[type=text],
.form-signin button {
width: 100%;
display: block;
margin-bottom: 10px;
z-index: 1;
position: relative;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

.btn.btn-signin:hover,
.btn.btn-signin:active,
.btn.btn-signin:focus {
background-color: rgb(12, 97, 33);
}

最佳答案

将列表的 max-height 设置为其父项的高度(或任何您需要的高度),然后将其 overflow 属性设置为 auto.

这是一个简单的例子:

div{
border:1px solid #000;
font-family:arial;
height:100px;
width:200px;
}
ul{
list-style:none;
max-height:100px;
margin:0;
overflow:auto;
padding:0;
text-indent:10px;
}
li{
line-height:25px;
}
li:nth-child(even){
background:#ccc;
}
<div>
<ul>
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
</ul>
</div>

关于html - 使无序列表可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29793160/

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