-3
A
回答
0
text-align: justify;
是否对齐。另外请注意,字体大小和重量是不同的。
0
你需要使用text-align
+ text-align-last
看到https://developer.mozilla.org/fr/docs/Web/CSS/text-align-last和https://css-tricks.com/almanac/properties/t/text-align-last/
p {
text-align:justify;
text-align-last:center;
}
/* makup*/
p {
width:400px;
margin:auto;
padding:1em;
border:solid black;
background:gray;
color:white
}
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
0
GCyrillus解决方案是正确的,但是请注意ŧ它不支持Safari,所以我想提出一些可能最适合你的方法,如果你希望有多浏览器的支持。
- 膜裹在一
<span>
标签最后一行 - 检查它的
width
(例如是260px
)和由p
的宽度减去它 - 想这是300px
(300px - 260px = 40px
) - 给双方
padding
到span
到中心(每边20px
)
p {
text-align: justify;
width: 300px;
margin: 0 auto;
background: black;
color: white;
padding: 20px;
font-family: sans-serif;
}
span {
padding: 0 20px;
}
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident hic impedit reprehenderit voluptates, voluptatibus ut explicabo, repudiandae, reiciendis soluta <span>facere in cum eveniet architecto sint.</span></p>
相关问题
- 1. 如何在openpyxl中进行coulmn对齐?
- 2. 使用css进行对齐和填充
- 3. 如何在css中对齐列内容
- 4. 如何在CSS中对齐网页
- 5. 我该如何对齐在CSS中的行中心的文本?
- 6. 如何在一行中水平对齐css/html中的按钮?
- 7. 我如何在Lua中对文字进行右对齐?
- 8. 如何与css对齐
- 9. CSS:如何在一行中对齐不同大小的图像?
- 10. 在CSS中垂直对齐?
- 11. 在CSS中对齐线条
- 12. 在css中修复对齐
- 13. CSS行对齐问题
- 14. 如何对齐CSS中的div?
- 15. 如何在Silverlight 4中使用RichTextBox进行选择对齐?
- 16. 如何在UILabel中进行2个对齐
- 17. HTML/CSS - 右对齐和左对齐在同一行上?
- 18. HTML如何在同一行中对两个单词进行不同对齐
- 19. 垂直对齐和行高在CSS
- 20. CSS - 中心对齐多行列表
- 21. css进度条的标签对齐
- 22. CSS头对齐
- 23. Css div对齐
- 24. HTML CSS对齐
- 25. CSS div对齐
- 26. html css对齐
- 27. CSS&DIV对齐
- 28. Woocommerce CSS对齐
- 29. CSS对齐框
- 30. 如何对齐表格外的文本与CSS左对齐
避免两端对齐在网络上 - https://ux.stackexchange.com/questions/24025/should-text-on-the-web-be-justified –
添加一个js小提琴帮助更多的获得更好的回答 – Rex
什么是js小提琴?你能举一个例子如何得到这样的结果吗? –