javascript - 自定义文本布局 CSS-JS

标签 javascript html css

<分区>


关闭 7 年前

这篇文章是 8 天前编辑并提交审核的。

我想要做的是,我希望我的文本的每一行都比它上面的行短(按宽度)。所以我的文本布局看起来就像我的文本在一个倒置的金字塔内。见下图:enter image description here

我如何设法使用 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/

上一篇:jquery - 如何使用 jQuery CSS 选择器设置背景颜色

下一篇:javascript - 在固定大小的 div 中带有文本标题的图像

相关文章:

javascript - Live Reload 在 6 秒后刷新,有时会被种植

css - 像按钮一样将 Facebook 定位在图像旁边

用于调整 Blogger 帖子中照片大小的 JavaScript

html - 创建右侧半圆的菜单(导航菜单)

jquery - 时间间隔设置 CSS 类

html - Chrome <span> 背景颜色

javascript - div 出现一秒钟然后再次隐藏?

javascript - 在 jQuery 中将 live() 变成 on()

javascript - 窗口中的 ('ontouchstart')返回 true 但没有触摸事件

javascript - Href 仅适用于 http