html – 字母间距错误的文本中心对齐
发布时间:2020-12-14 19:34:50 所属栏目:资源 来源:网络整理
导读:我注意到使用letter-spacing和text-align:center在一起的奇怪行为. 增加空间,使文本更靠近元素的左边距. HTML div p- Foo Bar Zan -/p/div CSS div { width: 400px; height:400px; background-color: #3b0d3b; text-align:center; margin:auto;}p { color:#
我注意到使用letter-spacing和text-align:center在一起的奇怪行为.
增加空间,使文本更靠近元素的左边距. HTML <div> <p>- Foo Bar Zan -</p> </div> CSS div { width: 400px; height:400px; background-color: #3b0d3b; text-align:center; margin:auto; } p { color:#fff; margin-top: 40px; text-align:center; padding-top:30px; font-size: 1.2em; letter-spacing:.9em; <--- Here is the problem } 我创建了a codepen to show what I mean. 解决方法
看来您需要将文本缩进与letter-spacing相同的数量.第一个字母没有施加到左侧的间距
http://codepen.io/anon/pen/bcahC .spacing-large { letter-spacing: 0.9em; text-align: center; text-indent: 0.9em; } 我不知道为什么会发生这种情况,也许别人可以解释它.我想出的唯一合乎逻辑的事情是,因为它是第一个字母,左侧的间距将不适用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |