如何在CSS文字下方实现点和线?

时间:2019-06-20 07:35:46

标签: html css

我想使用html和CSS设计以下内容。我也希望它能及时响应

Expected Output
下面是我尝试过的代码

<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style>
    .bullet {
      list-style-type: none;
    }
  </style>
</head>

<body>
  <div class="container">
    <ol class="bullet">
      <li>T1 </li>
      <li>
        &bull;
      </li>
      <li>T2</li>
    </ol>
  </div>
</body>

</html>

1 个答案:

答案 0 :(得分:2)

我的尝试

.timeline {
  position: relative;
  display: flex;
  flex-flow: row wrap;
  list-style: none;  
  line-height: 3;
  margin: 10px;
  padding: 0;
  color: #069;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 50%;
  height: 1px;
  width: 100%;
  background: currentColor;
}

.timeline li {
  position: relative;
  width: 50%; 
  color: inherit;
}

.timeline li:nth-child(-n + 2)::before {
   content: "";
   position: absolute;
   bottom: -5px;
   left: 2px;
   box-shadow: 0 0 0 4px #fff;
   width: 10px;
   height: 10px;
   background-color: currentColor;
   border-radius: 50%;
}
<ul class="timeline">
  <li>T1</li>
  <li>T2</li> 
  <li>T3</li>
  <li>T4</li>
</ul>

如果您需要在该行上放置更多点,请调整列表项的宽度,并将项目符号的数量更改为第n个子表达式(codepen demo,两行中有6个点)