html - 如何自动换行标题?
问题描述
以这段代码为例
.test {
width: 50%;
height: 50%;
}
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1 class="test">This is a Headindfdfdfdfdsdfsdffdfdfdfddfdfdfddfghfghfddfdfdfdfdfdfdfdfdfdffdffdfdffdg</h1>
</body>
</html>
我将标题的宽度限制为整个页面的一半,并且我希望文本一旦超出边距就可以自动换行。但它不起作用。
那么,如何自动(不使用</br>
)换行标题?
解决方案
.test {
width: 50%;
height: 50%;
word-break:break-word;
}
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1 class="test">This is a Headindfdfdfdfdsdfsdffdfdfdfddfdfdfddfghfghfddfdfdfdfdfdfdfdfdfdffdffdfdffdg</h1>
</body>
</html>
请注意,还有overflow-wrap
可以使用的。
推荐阅读
- azure - 如何将 Blobfuse 升级到最新版本
- android - 在 Android Studio 中使用外部 cmake 可执行文件
- docker - 在 Docker 构建中使用 pip install 时出现 ModuleNotFoundError
- linux - 错误:无法找到或加载主类 io.gatling.app.Gatling
- python - 什么是 TensorFlow 线性回归的 pytorch 等价物?
- objective-c - 将 objc 关联对象用于 IBOutletCollection
- c# - 如何从基类实例访问派生类属性
- python - 将模型内的张量流操作列表自动转换为 ListWrapper
- c# - 在多语言网站 Umbraco8 上获取页面的子级
- javascript - 在 JavaScript 中匹配大量数组元素的最有效方法是什么?