html - 调整滚动条大小的 CSS

标签 html css

又是我问了一个很小的问题!我制作了两个 div,一个包含另一个 div,第二个 div 在左侧有一些文本,在右侧有图像。代码运行良好,但当我调整它的大小时,我注意到文本形成线条以适合图像。有没有办法避免这种情况发生,不调整大小但出现滚动条?我在第二个 div 上尝试了 resize: both; 但结果相同......

div.div1 {
  background-color: #F1F1F1;
  border: 1px solid #CCCCCC;
  padding: 10px;
}

div.div2 {
  background-color: #e2d8ba;
  border: 1px solid #000000;
  padding: 10px;
  text-align: justify;
  overflow: auto;
}
<div class="div1">
  <div class="div2">
    <img src="http://www.dailyrecoverymeditations.com/forums/image.php?u=2057&dateline=1404850818" style="float:right; padding-left: 10px;"> 
    
    Testing Text Testing Text Testing Text Testing Text Testing Text Testing Text Testing Text Testing
  </div>
</div>

最佳答案

可以为div2设置一个固定的宽度,为两个DIV都定义overflow: auto,这样就会出现滚动条:

div.div1 {
  background-color: #F1F1F1;
  border: 1px solid #CCCCCC;
  padding: 10px;
  overflow: auto;
}

div.div2 {
  background-color: #e2d8ba;
  border: 1px solid #000000;
  padding: 10px;
  text-align: justify;
  overflow: auto;
  width: 1000px;
}
<div class="div1">
  <div class="div2">
    <img src="http://www.dailyrecoverymeditations.com/forums/image.php?u=2057&dateline=1404850818" style="float:right; padding-left: 10px;"> Testing Text Testing Text Testing Text Testing Text Testing Text Testing Text Testing Text Testing</div>
</div>

关于html - 调整滚动条大小的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42692915/

相关文章:

html - 动画打开后获取消息到 fate away

Css - 覆盖 Internet Explorer 特定样式

javascript - 制作一个像 VS Code 一样的水平控制台窗口

css - 如何在网页中显示手机壳背面(带有透明相机孔)等形状内的图像?

html - 发送带有 HTML5 音频标签的自定义 HTTP 请求 header

javascript - 垂直对齐

jquery - 选择所有相同类的元素并存储在字符串中

javascript - 在没有 jQuery 的情况下在 JavaScript 中查找单击的表格单元格的行和列

jquery - 使用当前背景颜色的 CSS 关键帧动画

jQuery/CSS : line-height of "normal" == ? 像素