html - 分词不遵循文本对齐
问题描述
我有一个 html,我需要在一个块中显示句子的换行,但它是浮动的。
我想让字符串的其余部分(未显示的部分 b/c 它的溢出)显示在“非常”字的下方。
HTML
<body class='login'><div id="header">
<div id="branding">
<h1 id="site-name"><a href="/">very long string that needs to be better displayed</a></h1>
</div>
</div></body>
CSS
#header #branding h1 {
margin: 0;
padding: 5px 10px;
text-indent: 190px;
background: white url(https://via.placeholder.com/150) 5px 0px no-repeat;
height: 136px;
width: 150px;
background-size: 150px;
white-space: pre;
}
.login #header h1 a {
color: black;
position: relative;
top: 50px;
}
如果我尝试overflow-wrap:break-word
它会显示如下:
解决方案
使用padding-left
sincetext-indent
只会影响第一行。不要忘记添加box-sizing:border-box;
以考虑宽度内的填充:
#header #branding h1 {
margin: 0;
padding: 5px 10px 5px 190px;
background: white url(https://via.placeholder.com/150) 5px 0px no-repeat;
width: 600px;
box-sizing:border-box;
background-size: 150px;
}
.login #header h1 a {
color: black;
position: relative;
top: 50px;
}
<div id="header">
<div id="branding">
<h1 id="site-name"><a href="/">very long string that needs to be better displayed</a></h1>
</div>
</div></body>
推荐阅读
- scala - Scala:如何解析字符串并生成嵌套向量的向量
- xml - 在 odoo11 中更新多个字段
- c# - 如何在标签上为其他属性调用 PropertyChanged
- django - 我有一个在本地服务器上运行的网站...需要帮助将其公开
- django - 如何在 Django 的 case 语句中使用聚合
- swift - 如果从 24 小时格式切换到 12 小时格式,则时间戳格式会更改
- reactjs - ReactJS - Fetch as Google 仅适用于主页,但不适用于其他路线?
- python - 正则表达式/Python:当正则表达式已经进行替换时,Python 中的替换
- java - Java:当字符串包含空字符时如何输出字符串?
- mysql - 如何在 JPA Query 中计算行表