css - 空白 nowrap 打破列布局
问题描述
没有white-space: nowrap
:
与white-space: nowrap
:
如何避免破坏此列布局?
.row {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto {
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.col {
-ms-flex-preferred-size: 0;
flex-basis: 0;
-ms-flex-positive: 1;
flex-grow: 1;
max-width: 100%;
}
.col-2 {
-ms-flex: 0 0 16.666667%;
flex: 0 0 16.666667%;
max-width: 16.666667%;
}
.wrapper {
white-space: nowrap;
overflow: auto;
border: solid 4px purple;
padding: 4px;
}
.wrap {
white-space: nowrap;
background: lightgrey;
display: inline-block;
}
p {
white-space: nowrap;
background: lightgreen;
display: inline-block;
}
<div class="row">
<div class="col-2">
two
</div>
<div class="col">
<div class="wrapper">
<div class="wrap">
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
</div>
<div class="wrap">
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
</div>
</div>
</div>
</div>
解决方案
你可以添加类容器
<div class="row container">
<div class="col-2">
two
</div>
<div class="col">
<div class="wrapper">
<div class="wrap">
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
</div>
<div class="wrap">
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>
</div>
</div>
</div>
</div>``
推荐阅读
- javascript - 将控制器中的 html 字符串绑定到模板不会触发点击事件
- c++ - 递增 ++i 与 i++
- ruby-on-rails - 使用正则表达式通过循环解析以仅显示匹配结果?
- angular - 如何在角度的 ag-grid 单元格中应用自定义 css 类?
- sql - 如何检查postgres表中的条目是否在增加
- java - 向类添加类型间公共静态方法
- java - 替换 RecyclerView 项中的片段时:容器的“没有找到 id 的视图”
- php - 多个数组 PHP
- wordpress - Wordpress 被插件损坏
- reactjs - 使用门户而不是将组件作为道具传递有什么缺点吗?