强制元素中的单行文本用 CSS 填充宽度 [英] Force single line of text in element to fill width with CSS
本文介绍了强制元素中的单行文本用 CSS 填充宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 div
元素,它包含一行文本.我怎样才能让这个文本填充宽度 100%?
I have a div
element that holds one line of text. How can I get this text to fill the width 100%?
text-align:justify
只作用于多行文本的元素,对单行的 div
没有影响.手动调整字母间距和字间距是丑陋且无效的.
text-align:justify
is only working on elements with several lines of text, and has no effect on the div
with single line. Manually adjusting the letter-spacing and word-spacing is ugly and ineffective.
还有其他选择吗?
推荐答案
试试这个:
div {
text-align: justify;
}
div:after {
content: "";
display: inline-block;
width: 100%;
}
查看此处了解更多信息.
这篇关于强制元素中的单行文本用 CSS 填充宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文