css - 用 CSS 对齐短线
问题描述
我想用 CSS 来证明一条非常短的线是合理的。,text-align: justify;
它不起作用。还有另一种方法可以做到这一点吗?
body {
margin: 0;
padding: 0;
width: 50%;
}
.justify {
font-family: Arial;
font-size: 30px;
width: 100%;
border: 1px solid red;
padding: 10px;
color: red;
text-align: justify;
}
<div class="justify">Justify this text</div>
将感谢您的帮助。:)
解决方案
text-align-last: justify;
改为使用
body {
margin: 0;
padding: 0;
width: 50%;
}
.justify {
font-family: Arial;
font-size: 30px;
width: 100%;
border: 1px solid red;
padding: 10px;
color: red;
text-align-last: justify;
}
<div class="justify">Justify this text</div>
或者如果不支持上述内容,则使用伪元素破解:
body {
margin: 0;
padding: 0;
width: 50%;
}
.justify {
font-family: Arial;
font-size: 30px;
width: 100%;
border: 1px solid red;
padding: 10px;
color: red;
text-align: justify;
height: 1.2em;
}
.justify::after {
content:"";
display:inline-block;
width:100%;
}
<div class="justify">Justify this text</div>
推荐阅读
- laravel - 更改返回视图以在 laravel 搜索功能上返回路线
- python - 如何从安全 FTP 服务器读取 CSV
- swiftui - 使用自定义导航栏和 TabView SwiftUI 时向后滑动
- java - XSLT - 屏蔽数据 - 以其他标签为条件
- omnet++ - 是否可以在基于 m1 的 Mac 中运行 Omnetpp IDE?
- javascript - react js文本编辑器中的富文本溢出
- java - 来自 Bundle getExtras 的 Spanabe 字符串文本
- javascript - 如果单词存在于术语数组中,则遍历所有节点并将每个单词包装在一个跨度中
- spring-boot - Apache Camel 调用 https 休息服务不能通过代理工作
- selenium-webdriver - 我正在以页面对象模型的方式编写代码并使用 Cucumber