How to create a dot / small circle under text?

你离开我真会死。 提交于 2020-07-03 07:12:48

问题


How can I make a dot under text using only CSS as shown in below picture?

The picture needs to be always in middle with any length of string. Probably I need to use :before OR :after? I've tried but result was awful.


回答1:


A transformed pseudo element can be used to create this:

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>



回答2:


.char {
    display: inline-block;
    position: relative;
}
.char::before {
    content: '.';
    display: inline-block;

    position: absolute;
    bottom: -0.5em;
    left: 0;

    text-align: center;
    width: 100%;

}

After writing this question on stack i come up with idea:) Its works excatly like I want :)



来源:https://stackoverflow.com/questions/44236541/how-to-create-a-dot-small-circle-under-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!