gpt4 book ai didi

CSS居中文本和可调大小

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

我正在尝试在 CSS 中创建一个“优先级标记”。我有几个问题。 第一:文本根本没有合理居中。 第二:我希望宽度(至少)随着文本的长度动态变化。两者都可行吗?

结果:enter image description here

我对如何选择适合这种情况的字体的理解超出了我目前的 CSS 技能。如果这已经完成,我真的不在乎重新发明它......

.box {
border-color: orange;
border-style: solid;
text-align: center;
border-width: 1px 0px 1px 1px;
margin: 0px 8px 0px 0px;
background-color: yellow;
padding-right: 8px;
position: relative;
height:14px;
width:20px;
}
.arrow {
border-color: transparent transparent transparent orange;
border-style: solid;
border-width: 8px;
position: absolute;
right: -15px;
bottom: -1px;
height:0;
width:0;
}
.arrow2 {
border-color: transparent transparent transparent yellow;
border-style: solid;
border-width: 7px;
position: absolute;
right: -12px;
bottom: 0px;
height:0;
width:0;
}

<div class="{style.box}">42
<div class="{style.arrow}"></div>
<div class="{style.arrow2}"></div>
</div>

最佳答案

将此添加到 .box:

font-size:12px;
font-family:serif;
display:inline-block;
padding-left:5px;

并移除其宽度规则。

关于CSS居中文本和可调大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6778834/

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