在 Div 内的段落中添加垂直滚动条

新手上路,请多包涵

我在 Div 中有一个段落。现在该段落的内容越来越多,因为我计划添加一些图像,但我的 div 的固定高度为 600px; 所以我的段落所以如果垂直滚动条被添加对于我的段落,它将解决我的问题..

这是我的布局的 HTML ..

  <div id="bodydesc" style="margin-left:auto; margin-right:auto; width:960px; height: 600px;">

            <p id="desc" style="float:left;color: #666666; width:700px; font-family: Candara,Trebuchet MS,sans-serif; font-size: 12px; font-weight: bold; border-right: thin dotted #666666; line-height: 18px;">

              //Here is my large content with images...

            </p>

 </div>

所以我的问题是如何在 HTML 的 div 内的段落中获得垂直滚动条…请帮助我..提前致谢..

原文由 user3725571 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 349
2 个回答

简短快速的回答,通过将 overflow-y 添加到 style 属性,将滚动条添加到 #bodydesc --- :

 <div id="bodydesc" style="margin-left:auto; margin-right:auto; width:960px; height: 600px; overflow-y: scroll;">

    <p id="desc" style="float:left;color: #666666; width:700px; font-family: Candara,Trebuchet MS,sans-serif; font-size: 12px; font-weight: bold; border-right: thin dotted #666666; line-height: 18px;">

      //Here is my large content with images...

    </p>

</div>

我的前端开发人员坚持要我告诉你将所有这些样式声明移动到 外部 css 文件 中。

原文由 Jonas Grumann 发布,翻译遵循 CC BY-SA 4.0 许可协议

添加 overflow-y: scroll; 到您的段落

原文由 Tobiasz 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏