如何在文本下创建一个点/小圆圈?
How to create a dot / small circle under text?
如何仅使用 CSS 在文本下方打一个点,如下图所示?
图片需要始终在任意长度的字符串中间。
可能我需要使用 :before
或 :after
?我试过了,但结果很糟糕。
.char {
display: inline-block;
position: relative;
}
.char::before {
content: '.';
display: inline-block;
position: absolute;
bottom: -0.5em;
left: 0;
text-align: center;
width: 100%;
}
在堆栈上写下这个问题后,我想出了一个主意:)它的工作原理和我想要的一样:)
转换后的伪元素可以用来创建这个:
body { text-align: center; }
.text {
display: inline-block;
vertical-align: top;
padding-bottom: 10px;
position: relative;
text-align: center;
padding: 20px 10px;
line-height: 24px;
min-width: 100px;
background: #333;
font-size: 20px;
color: #fff;
}
.text::before {
transform: translateX(-50%);
border-radius: 100%;
position: absolute;
background: blue;
bottom: 10px;
height: 8px;
content: '';
width: 8px;
left: 50%;
}
<div class="text">about</div>
如何仅使用 CSS 在文本下方打一个点,如下图所示?
图片需要始终在任意长度的字符串中间。
可能我需要使用 :before
或 :after
?我试过了,但结果很糟糕。
.char {
display: inline-block;
position: relative;
}
.char::before {
content: '.';
display: inline-block;
position: absolute;
bottom: -0.5em;
left: 0;
text-align: center;
width: 100%;
}
在堆栈上写下这个问题后,我想出了一个主意:)它的工作原理和我想要的一样:)
转换后的伪元素可以用来创建这个:
body { text-align: center; }
.text {
display: inline-block;
vertical-align: top;
padding-bottom: 10px;
position: relative;
text-align: center;
padding: 20px 10px;
line-height: 24px;
min-width: 100px;
background: #333;
font-size: 20px;
color: #fff;
}
.text::before {
transform: translateX(-50%);
border-radius: 100%;
position: absolute;
background: blue;
bottom: 10px;
height: 8px;
content: '';
width: 8px;
left: 50%;
}
<div class="text">about</div>