gpt4 book ai didi

css - 形状外和垂直对齐的文本

转载 作者:行者123 更新时间:2023-11-28 10:14:21 25 4
gpt4 key购买 nike

如何垂直对齐 block 内的文本?如果不制动左侧具有 shape-outside 属性的元素,我无法做到这一点。

.a {
width: 150px;
height: 300px;
background-color: yellow;
}

.b {
float: left;
-webkit-shape-outside: polygon(0% 50%, 100% 0%, 0% 0%, 0% 100%, 100% 100%);
-webkit-clip-path: polygon(0% 50%, 100% 0%, 0% 0%, 0% 100%, 100% 100%);
width: 100%;
height: 100%;
background-color: black;
}

.c {
font-family: Arial;
font-size: 16px;
text-align: right;
}
<div class="a">
<div class="b"></div>
<div class="c">text text text text text text text text text text text text text text text text text text</div>
</div>

图像显示了我拥有的东西和我想要完成的东西。

example

父元素的高度和文本的长度是不固定的。

最佳答案

您可以使用 calc(50% + 30px); 来实现 padding-top

calc is support here

http://jsfiddle.net/yt4py6oa/5/

.c {
position:relative;
font-family:"Arial";
font-size:16px;
text-align:right;
padding-top: calc(50% + 30px);
}

关于css - 形状外和垂直对齐的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32713601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com