html - 避免文本增加元素的大小
问题描述
我有两个 div - 一个是固定高度,另一个使用弹性框占用其余的水平空间:
#first
{
width:300px;
height: 200px;
background-color:#F5DEB3;
}
#second
{
width:300px;
background-color: #9ACD32;
-webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
-moz-box-flex: 1; /* OLD - Firefox 19- */
-webkit-flex: 1; /* Chrome */
-ms-flex: 1; /* IE 10 */
flex: 1; /* NEW, */
}
当底部的 div 里面有长文本时,如何防止底部 div 扩展?(虽然仍然只占用剩余的水平空间。)
解决方案
好吧,你想对不合适的文本做什么?
你可以用overflow
.
把它藏起来:
#second
{
width: 300px;
background-color: #9ACD32;
flex: 1;
overflow: hidden;
}
添加卷轴:
#second
{
width: 300px;
background-color: #9ACD32;
flex: 1;
overflow: scroll; // overflow: auto;
}
推荐阅读
- java - 执行某些代码时,我在 android studio 中的应用程序崩溃
- file - avro 和 parquet 格式的数据是否必须在 hadoop 基础架构中写入?
- c++ - 在 C++ 代码中查找编号函数?
- node.js - 是否可以仅获取 sequelize 属性的值?
- javascript - C# 和 javascript 之间的加密结果差异
- javascript - 有没有办法让 Node.JS 在执行我的 Dialogflow 输出函数之前先执行我的 MySQL 函数?
- exoplayer2.x - 更改当前播放剪辑的持续时间
- php - 看看我是否误解了 numberformatter 或者我是否错误地使用它来解析和验证
- gitlab-ci - 如何在 GitLab 管道的各个阶段之间保留 docker 映像实例?
- java - 如何停止警报声