Html 如何在div中添加滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28275546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:26:28  来源:igfitidea点击:

how to add scrollbar in div

htmlcssscrollbar

提问by Klevi

I want to add a scrollbarto div id="kryesore"in mainpage,when i try it doesn't work.Can you tell me what can i do and how can i fix it?

我想在主页上添加一个scrollbardiv id="kryesore",当我尝试时它不起作用。你能告诉我我能做什么,我该如何解决它?

below 2 screenshot how it look like : l

下面 2 个屏幕截图它的样子:l

回答by Prashant Bhujbal

change the line

换线

<div id="kryesore">

to

<div id="kryesore" style="overflow-y: scroll;">

or you can write in your css or style tag in head as

或者你可以在你的 css 或 style 标签中写成

#kryesore
{
   overflow-y:scroll;
}

working for me.

为我工作。

回答by Luca Detomi

Use overflowproperty to add scrollbar only when necessary:

overflow仅在必要时使用属性添加滚动条:

#kryesore
{
   overflow-y:auto;
}

回答by Pattle

You can use the overflow-yproperty by doing

您可以overflow-y通过执行以下操作来使用该属性

#kryesore
{
   overflow-y:scroll;
}

overflow-ywas only support from IE9 onward so if you are using an older version of IE you could just use overflow

overflow-y仅从 IE9 开始支持,因此如果您使用的是旧版本的 IE,则可以使用 overflow

#kryesore
{
   overflow:scroll;
}