css - 为什么连字符似乎不适用于字符 :before 和首字母缩写 ::first-letter?
问题描述
这是 html 部分的代码片段:
<p class="chapter">Introduction</p>
使用以下 css,“介绍”不与缩放或窗口大小调整连字符?
我不明白为什么连字符无处不在:
body {
-webkit-hyphens: auto; /* manual (default), auto, none */
-moz-hyphens: auto;
-ms-hyphens: auto;
-o-hyphens: auto;
-hyphens: auto;
}
除了以下 = 带有字符 :before 和 ::first-letter 代码的首字母下沉...
.chapter:before {
display: inline;
/*
content: '\00a7\00a0'; // § + non-breaking space //
*/
content: '§';
/* don't need the above non-breaking space with this padding */
padding-right: 0.3em;
font-size: 1.4em;
font-weight: bold;
color: #600;
}
/*
https://css-tricks.com/snippets/css/drop-caps/
*/
.chapter + p::first-letter {
float: left;
font-family: Georgia, "Times New Roman", serif;
color: #903;
font-size: 250%;
line-height: 100%; /* original = 1 */
position: relative; /* tweaking the placement ... */
top: -.05em;
padding-right: 0.06em; /* original = 5px */
padding-left: 0.00em; /* original = 0px */
}
这是一个或两个快照...
请注意,第一个不连字符,但第二个呢???
更神秘的是,如果我使用“Introduction q”,即> one word,连字有效,但不是 = one word?
谢谢一堆和一堆...
解决方案
代替:
body {
-webkit-hyphens: auto; /* manual (default), auto, none */
-moz-hyphens: auto;
-ms-hyphens: auto;
-o-hyphens: auto;
-hyphens: auto;
}
... 用这个:
body {
-webkit-hyphens: auto; /* manual (default), auto, none */
-moz-hyphens: auto;
-ms-hyphens: auto;
-o-hyphens: auto;
-hyphens: auto;
overflow-wrap: break-word; /* BINGO! */
word-wrap: break-word;
}
仅归功于:
参考:https ://justmarkup.com/articles/2015-07-31-dealing-with-long-words-in-css/
推荐阅读
- bash - BASH 仅在单个字母不在单词中时替换单个字母
- javascript - 如何从 element.all each 返回一个元素
- php - 与 MongoDB 的 PHP 连接不起作用并响应“试图获取无价值的属性”
- python - 如何跳过按 Enter 继续使用 python 在 shell 命令中
- android - Phaser 2:游戏不加载到 WebView
- quickbooks - Consolibyte QuickBooks PHP 库 - 您如何调试/查看错误?
- linux - 在 Linux 中添加脚本以在启动终端 bash shell 时显示日期
- java - 如果测试失败,重试 TestNG 代码中的特定代码,而不是整个测试
- python - 如何在 Pandas 单元格中生成字符串计数的 Python 数据透视表?
- django - URLconf 中似乎没有任何模式/循环导入错误