gpt4 book ai didi

html - 如何将这些 css 三 Angular 形与文本垂直对齐?

转载 作者:太空宇宙 更新时间:2023-11-04 01:19:13 24 4
gpt4 key购买 nike

div {
margin: 10px;
}

.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
vertical-align: top;
}

.arrow-down {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid red;
vertical-align: bottom;
}
<div>
<span class="arrow-up"></span> An up arrow
</div>
<div>
<span class="arrow-down"></span> A down arrow
</div>

https://jsfiddle.net/dL1od5tz/8/

我想对齐它们,使箭头底部与文本底部对齐。 vertical-align 似乎没有做任何事情,设置边距和填充也没有用。我没主意了。谢谢!

最佳答案

让它们成为每个 inline-block 怎么样?

div {
margin: 10px;
}

.arrow {
display: inline-block;
}

.up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
}

.down {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid red;
vertical-align: bottom;
}
<div>
<span class="arrow up"></span>
<span>An up arrow</span>
</div>
<div>
<span class="arrow down"></span>
<span>A down arrow</span>
</div>

关于html - 如何将这些 css 三 Angular 形与文本垂直对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49477876/

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