html - 在“V”形内将 CSS 中的文本居中
问题描述
我有这张照片。
这在 CSS 中可能吗?
现在我知道你可以使用text-align: center
,我什至可以让每一行成为一个跨度并逐渐增加填充,但是有没有我不知道的属性,比如从中心到中心,或者类似的东西?
这感觉很明显,但我就是想不出一个合理的方法。
更新
问题是因为在图片中,文本趋向于在底部变短,就像字母 V 一样,所以 t 从宽开始逐渐变窄。
我从来没有见过类似的事情,所以很好奇。
解决方案
shape-outside 可以做到:
.wrapper {
display:flex; /* this is needed for the percentage height */
}
.box {
font-size: 25px;
text-align:justify;
}
.box > div,
.box::before{
height:150%; /* should be at least 100% but we consider bigger to avoid overflow */
width:100px; /* adjust this */
}
.box > div {
float:right;
shape-outside:linear-gradient(to bottom right,#0000 50%,#000 0);
}
.box::before {
content:"";
float:left;
shape-outside:linear-gradient(to bottom left,#0000 50%,#000 0);
}
/* the below is not need, it's only to illustrate the shape
uncomment it to see what is happening
.box > div {
background:linear-gradient(to bottom right,#0000 50%,red 0);
}
.box::before {
background:linear-gradient(to bottom left,#0000 50%,green 0);
}
*/
<div class="wrapper">
<div class="box">
<div></div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pretium lacus ipsum, at placerat nunc sollicitudin scelerisque. Donec vulputate ex odio, et facilisis nisi tristique et. Maecenas tortor nisi, euismod et tellus sit amet, tincidunt congue
eros. Nam et viverra magna, id ultricies augue.
</div>
</div>
推荐阅读
- android - 无法使用 gem5 的 .rcS 脚本启动 android
- c# - 在已部署的 Web 应用程序中发送电子邮件失败
- c++ - 当函数可能失败并需要调用者重试时,是否有完美转发的设计模式?
- html - 与地址栏一起使用
- reactjs - 在事件发生之前执行动作
- python - Nginx:Linux 服务器上的内部端口转发
- sql - 如何优化结合了 INNER JOIN、DISTINCT 和 WHERE 的 SQL 查询?
- python - 为什么整数可以存储十六进制值但不能存储相同的十进制值?
- r - 如何使用 R 从 ECMWF 数据存档中下载 ERA-Interim 数据?
- php - 通过 PHP MYSQL 创建循环 JSON 不使用不同的查询