- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的文档相关部分的布局:
<!-- ↑ more sections -->
<section>
<h2>Header 2</h2>
<div class="subsection">
<div><h3>Header 3</h3></div>
<div>
<h4>Header 4</h4>
<div class="body-text"><!-- Parsed markdown text --></div>
<h4>Header 4</h4>
<div class="body-text"><!-- Parsed markdown text --></div>
<!-- ↓ And so on... -->
</div>
</div>
<div class="subsection">
<div><h3>Header 3</h3></div>
<div>
<h4>Header 4</h4>
<div class="body-text"><!-- Parsed markdown text --></div>
<!-- ↓ And so on... -->
</div>
</div>
<div class="subsection">
<div><h3>Header 3</h3></div>
<div>
<h4>Header 4</h4>
<div class="body-text"><!-- Parsed markdown text --></div>
<!-- ↓ And so on... -->
</div>
</div>
<!-- ↓ and so on... -->
</section>
<!-- ↓ more secitons -->
看起来像:
h2
之间中断和第一个 .subsection
; h4
之间中断和它的 .body-text
; .body-text
之间中断和 h4
跟随它; .body-text
内突破如果时间太长; .subsection
之间中断和另一个 .subsection
/* Borders to show where I do and do not want breaks in the following screenshot */
h2 {
break-before: auto; /* ✅ */
break-after: avoid; /* ❌ */
border-top: 1px solid forestgreen !important;
border-bottom: 1px solid red !important;
}
.subsection:first-of-type {
break-before: avoid; /* ❌ */
break-after: auto; /* ✅ */
border-top: 1px solid red !important;
border-bottom: 1px solid forestgreen !important;
}
h4 {
break-before: auto; /* ✅ */
break-after: avoid; /* ❌ */
border-top: 1px solid forestgreen !important;
border-bottom: 1px solid red !important;
}
.subsection:first-of-type h4 {
break-before: avoid; /* ❌ */
border-top: 1px solid red !important;
}
.body-text {
break-before: avoid; /* ❌ */
break-after: auto; /* ✅ */
border-top: 1px solid red !important;
border-bottom: 1px solid forestgreen !important;
}
这似乎与我上面概述的内容相当。然而,我看到
break-*: auto;
, 有
h4
及其以下
.body-text
.
是什么阻止它立即突破绿线break-inside: avoid;
在
sections
:
section {
break-inside: avoid;
background-color: rgba(255, 0, 0, 0.25);
}
/* ↓ CSS from above... ↓ */
section
内部中断s。只是这是唯一的
.subsections
实际上是 Vue 组件,其中
section
的组成部分。我不明白这是怎么回事
最佳答案
break-inside: avoid
在 section
并不意味着 section
永远不能有分页符。这意味着如果可能的话应该避免它。
看起来您确实希望在 .subsection
中允许分页符div,反对在 section
里面. page-break: avoid
在 .subsections
是什么导致他们在不合适时转到下一页。
/*prevent page breaking inside section, when a section doesn't fit it will display on the next page */
section {
break-inside: avoid;
}
/*try not to break between h2 and section*/
h2 + .subsection {
break-before: avoid;
}
如何考虑分页符
page-break: inside
: 将这个元素内的所有内容粘合在一起。它将尝试充当单个块。
break-before: avoid
: 将它之前的元素粘到当前元素上,以便它们尝试充当单个块。
break-after: avoid
: 将它后面的元素粘到当前元素上,以便它们尝试充当单个块。
关于CSS Paged Media : Cannot achieve desired breaking behaviour (break-after, 休息前什么都不做),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62486806/
是否有效率偏好以下控制流选项之一用于循环或切换另一个? 选项 1: switch(...){ case 1: if (...) { ... } else if
我需要在某个地方修复一些 CSS,因为我的文本没有环绕,如果它是一个非常长的单词,它会无限期地继续下去。 在大多数情况下,我在我的 CSS 文件中尝试了 word-wrap: break-word;
这个问题在这里已经有了答案: What is the difference between "word-break: break-all" versus "word-wrap: break-word
我的问题: overflow-wrap: break-word 和 word-break: break-word 有区别吗? 非重复: 这里有一些现有的问题,乍一看可能是重复的,但实际上不是。 Wha
我目前想知道两者之间有什么区别。当我同时使用它们时,如果它不适合容器,它们似乎会打破这个词。但为什么 W3C 做了两种方式来做呢? 最佳答案 word-wrap: break-word 最近更改为 o
满足条件时如何跳出循环? 例如: for (i in 0..10){ if (i==3){ // equivalent of break } } 最佳答案 Q#没有中
CSS3 规范说部分支持 word-wrap:break-word; 在 Chrome 中你必须使用 word-wrap:break-all; 但是没有连字符。我正在使用 text-align:jus
我想在我的 View 列表中显示来自数据库的所有评论。但有时,评论会很长。我试图用 word-wrap:break-word 来“打破”它们,但没有结果——像这样的评论 aaaaaaaaaaaaaaa
我正在尝试将一个长 URL 放置在侧边栏中,以在表格单元格宽度的范围内中断和换行。我已将 style="word-break:break-all;" 添加到 td 和围绕文本和 URL 的 span
我有以下代码: public void post(String message) { final String mess = message; (new Thread() {
是否有 word-break: break-word 的 alternative 可以在 firefox 中使用? 在 firefox[版本 57.0] 中 在 Chrome [版本 62.0.320
在this question以及this blog ,其中提到了样式 word-break 及其值。此外,还有值 break-word 作为属于例如的东西。 自动换行类。 在最近的 VS 中 MVC
我正在尝试将文本包装在 td 中并使用以下样式 word-break:break-all 在 IE 中工作得很好,但在 Firefox 中失败,请注意这是不支持的!尝试了 http://petesbl
我正在使用“word-break: break-all”在任何字符之间插入分隔符。 但是,在 Chrome 中,它无法正常处理特定字符(例如冒号、分号、逗号),如下所示。 (我的代码笔在这里:http
它只有在我用不同的元素包裹 anchor 标记时才有效,但我正在阅读 html,所以我想将它添加为整个页面的样式。 最佳答案 我不确定你想在这里实现什么,如果你能分享一些代码片段会很好。 无论如何,我
这些看起来都是一样的,有什么区别? https://jsfiddle.net/pmuub8w1/2/ p{ word-break:normal; } p{
目前下面的代码,保持div宽度固定,换行由于break-all .Test{ float: left; margin-bottom: 2px; word-wrap:break-word; word-b
我正在使用 word-break: break-all; 并想知道如何让浏览器自动插入 hyphens ,如 MDN example 中所示. div { width: 80px; heigh
我的 html 有这种结构: content1 content2 content3 content4 content5 content6 co
我正在尝试对齐图像旁边的文本。我想考虑没有空格的长字符串。 我的css如下 .new_item { width: 100%; float: left; border-bottom: 1px solid
我是一名优秀的程序员,十分优秀!