我需要在每张卡上,一个灵活的方向:列文本,当展开,文本显示正常THIS IS THE DESIRED EFFECT
这是我的HTML:
.expanding-cards {
display: flex;
width: 100%;
height: 35vh;
align-items: stretch;
flex-direction: row;
gap: 1rem;
}
.expanding-cards h3 {
display: inline-block;
flex-direction: column;
z-index: 3000;
}
.expanding-cards>* {
width: 0;
position: relative;
flex: 1;
transition: all 0.15s ease-out;
}
.expanding-cards>*.expanded {
flex: 3;
}
.expanding-cards>*.expanded h3 {
display: block;
z-index: 3001;
flex-direction: row;
}
.expanding-cards>* img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
<div class="row">
<div class="expanding-cards">
<div class="expandcard">
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210203171024/CSSTutorial.png">
<h3>
Canada
</h3>
</div>
<div class="expandcard expanded">
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210203171024/CSSTutorial.png">
</div>
<div class="expandcard">
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210203171024/CSSTutorial.png">
</div>
<div class="expandcard">
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210203171024/CSSTutorial.png">
</div>
<div class="expandcard">
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210203171024/CSSTutorial.png">
</div>
</div>
</div>
我还有一个js文件,它可以在单击时添加和删除类“expanded”。
2条答案
按热度按时间vulvrdjw1#
writing-mode
.来改变文本的方向。crard
没有悬停的地方,我们保持文本为writing-mode: vertical-lr;
,垂直模式,当卡悬停时,我们可以使用writing-mode: vertical-lr;
,水平模式。x一个一个一个一个x一个一个二个x
zzwlnbp82#
我只需要添加文本和调整z索引。我想下面是你想要的结果