<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
这篇文章是 8 天前编辑并提交审核的。
标签 javascript html css
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
这篇文章是 8 天前编辑并提交审核的。
我想要做的是,我希望我的文本的每一行都比它上面的行短(按宽度)。所以我的文本布局看起来就像我的文本在一个倒置的金字塔内。见下图:
我如何设法使用 CSS、JavaScript 或任何可能的方法来做到这一点?
根据要求,这是一个没有效果的可重现代码示例:
<div style="text-align: center">Pro. Doç. Dr. John DOE.</div>
<div style="text-align: center">
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin<br/>
literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at</br>
Sydney College in Virginia, looked up one of the more obscure Latin words,</br>
Ipsum passage, and going through the cites of the word in</br>
discovered the undoubtable source.
</div>
最佳答案
尝试为您的容器元素(可能是一个 div)提供 css 属性 text-align:center
.然后你的整个文本将在这个 div 中居中。现在设置 <br>
-在您的文本中添加标签,使其在所需位置中断。
关于javascript - 自定义文本布局 CSS-JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33519777/