gpt4 book ai didi

html - 将垂直文本保留在容器内

转载 作者:行者123 更新时间:2023-12-04 07:14:49 25 4
gpt4 key购买 nike

我目前正在尝试创建一些卡片,其中包含有关玩家的一些详细信息。玩家的名字垂直显示在卡片上,我已经放置了 absolutely .问题在于,随着名称变长,名称会向下扩展,而不是从底部到顶部齐平。我已经尝试了几种解决方案,但无法正常工作。这甚至可能吗?还是transform这里的值只会引起问题吗?
我想要实现的是:
enter image description here

.potw-section{
background-color: #111;
}

.container{
width: 100%;
max-width: 1260px;
margin: 0 auto;
padding: 0 1.875rem;
box-sizing: border-box;
}

.potw-grid{
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto;
gap: 0px 90px;
}

.potw-card{
display: flex;
position: relative;
width: 100%;
align-items: center;
}

.potw-meta{
position: absolute;
left: 0;
top: 0;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
color: #fff;
font-size: 1.563rem;
line-height: 29px;
text-transform: uppercase;
font-weight: 700;
width: 95px;
background: linear-gradient(90deg, rgba(17, 17, 17, 0.7) 62.11%, rgba(17, 17, 17, 0.5) 62.11%, rgba(0, 0, 0, 0) 122.11%);
}

.potw-meta-inner{
display: flex;
flex-direction: column;
padding: 1.25rem 0;
}

.potw-value{
display: flex;
flex-direction: column;
align-items: center;
font-size: 1.563rem;
line-height: 29px;
text-transform: uppercase;
font-weight: 700;
margin-bottom: 1.25rem;
}

.potw-value img{
max-height: 30px;
}

.potw-outline{
position: absolute;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #fff;
font-size: 2.188rem;
line-height: 39px;
text-transform: uppercase;
font-weight: 700;
left: -46%;
bottom: 27%;
letter-spacing: 2px;
transform: rotate(270deg);
}
<div class="potw-section">
<div class="container">
<div class="potw-grid">
<div class="potw-card">
<p class="potw-outline">Malte Delow</p>
<div class="potw-meta">
<div class="potw-meta-inner">
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<img src="https://i.ibb.co/KWgnKvh/lakers.png" >
</div>
</div>
</div>
<img src="https://i.ibb.co/NFxXnZm/potw-player.png">
</div>
<div class="potw-card">
<p class="potw-outline">Malte Delow</p>
<div class="potw-meta">
<div class="potw-meta-inner">
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<img src="https://i.ibb.co/KWgnKvh/lakers.png" >
</div>
</div>
</div>
<img src="https://i.ibb.co/NFxXnZm/potw-player.png">
</div>
<div class="potw-card">
<p class="potw-outline">Longer Name Delow</p>
<div class="potw-meta">
<div class="potw-meta-inner">
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<img src="https://i.ibb.co/KWgnKvh/lakers.png" >
</div>
</div>
</div>
<img src="https://i.ibb.co/NFxXnZm/potw-player.png">
</div>
</div>
</div>
</div>

最佳答案

使用选项之一 transform-originpotw-outline

.potw-section{
background-color: #111;
}

.container{
width: 100%;
max-width: 1260px;
margin: 0 auto;
padding: 0 1.875rem;
box-sizing: border-box;
}

.potw-grid{
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto;
gap: 0px 90px;
}

.potw-card{
display: flex;
position: relative;
width: 100%;
align-items: center;
}

.potw-meta{
position: absolute;
left: 0;
top: 0;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
color: #fff;
font-size: 1.563rem;
line-height: 29px;
text-transform: uppercase;
font-weight: 700;
width: 95px;
background: linear-gradient(90deg, rgba(17, 17, 17, 0.7) 62.11%, rgba(17, 17, 17, 0.5) 62.11%, rgba(0, 0, 0, 0) 122.11%);
}

.potw-meta-inner{
display: flex;
flex-direction: column;
padding: 1.25rem 0;
}

.potw-value{
display: flex;
flex-direction: column;
align-items: center;
font-size: 1.563rem;
line-height: 29px;
text-transform: uppercase;
font-weight: 700;
margin-bottom: 1.25rem;
}

.potw-value img{
max-height: 30px;
}

.potw-outline{
position: absolute;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #fff;
font-size: 2.188rem;
line-height: 39px;
text-transform: uppercase;
font-weight: 700;
bottom:0;
left:10%;
letter-spacing: 2px;
transform: rotate(270deg);
transform-origin:0 100%;
}
<div class="potw-section">
<div class="container">
<div class="potw-grid">
<div class="potw-card">
<p class="potw-outline">Malte Delow</p>
<div class="potw-meta">
<div class="potw-meta-inner">
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<img src="https://i.ibb.co/KWgnKvh/lakers.png" >
</div>
</div>
</div>
<img src="https://i.ibb.co/NFxXnZm/potw-player.png">
</div>
<div class="potw-card">
<p class="potw-outline">Malte Delow</p>
<div class="potw-meta">
<div class="potw-meta-inner">
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<img src="https://i.ibb.co/KWgnKvh/lakers.png" >
</div>
</div>
</div>
<img src="https://i.ibb.co/NFxXnZm/potw-player.png">
</div>
<div class="potw-card">
<p class="potw-outline">Longer Name Delow</p>
<div class="potw-meta">
<div class="potw-meta-inner">
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<span>PPG</span>
<span>28</span>
</div>
<div class="potw-value">
<img src="https://i.ibb.co/KWgnKvh/lakers.png" >
</div>
</div>
</div>
<img src="https://i.ibb.co/NFxXnZm/potw-player.png">
</div>
</div>
</div>
</div>

关于html - 将垂直文本保留在容器内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68830807/

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