css - 创建与垂直线和水平线相连的 CSS 圆圈

标签 css

我想在 CSS 中创建一个在右边和底部有线条的圆。类似下图。我找到了一个 css code水平连接圆圈。我不知道如何垂直添加线条或类似于我附加的图像?

enter image description here

  <!DOCTYPE html>
  <html lang="en">
      <head>
          <meta charset="utf-8">
          <style>
            @import "compass/css3";

            li {
                width: 2em;
                height: 2em;
                text-align: center;
                line-height: 2em;
                border-radius: 1em;
                background: dodgerblue;
                margin: 0 1em;
                display: inline-block;
                color: white;
                position: relative;
            }

            li::before {
                content: '';
                position: absolute;
                top: .9em;
                left: -4em;
                width: 4em;
                height: .2em;
                background: dodgerblue;
                z-index: -1;
            }

            li:first-child::before {
                display: none;
            }

            .active {
                background: dodgerblue;
            }

            .active ~ li {
                background: lightblue;
            }

            .active ~ li::before {
                background: lightblue;
            }

            body {
                font-family: sans-serif;
                padding: 2em;
            }
        </style>
     </head>
     <body>
         <ul>
             <li>1</li>
             <li>2</li>
             <li>3</li>
             <li class="active">4</li>
             <li>5</li>
             <li>6</li>
             <li>7</li>
         </ul>
     </body>
 </html>

最佳答案

使用伪元素的组合来实现目标。

ul {
  list-style: none;
  margin: 50px;
  padding: 0;
  font: normal 16px/22px Arial;
  color: #999;
}
li {
  overflow: hidden;
  position: relative;
  padding: 0 0 10px 35px;
  }
  li::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 9px;
    width: 20px;
    height: 999px;
    border: 2px solid lightblue;
    border-width: 2px 0 0 2px;
    }
    li:last-child::before {
      border-width: 2px 0 0;
      }
  li::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid lightblue;
    border-radius: 50%;
    }
  li.current,
  li.passed {
    color: #000;
    }
    li.current::before {
      border-top-color: dodgerblue;
      }
    li.current::after {
      border-color: dodgerblue;
      background: dodgerblue;
      }
    li.passed::before,
    li.passed::after {
      border-color: dodgerblue;
      }
<ul>
  <li class="passed">Step #1</li>
  <li class="passed">Step #2</li>
  <li class="passed">Step #3</li>
  <li class="current">Step #4<br><small><i>Description of the step</i></small></li>
  <li>Step #5</li>
  <li>Step #6</li>
  <li>Step #7</li>
</ul>

参见 jsfiddle如果你愿意

关于css - 创建与垂直线和水平线相连的 CSS 圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36929965/

相关文章:

html - Bootstrap 3 导航栏居中菜单

php - Moodle 3.3.2 更改默认字体

html - KnockOutJS 条件注释在 HTML 中添加空格

javascript - 是否可以在 Protractor 中单击绝对定位的伪元素

javascript - CSS 水平滚动,如何将 "below"定位在 "right"之前?

html - :link 的奇怪之处

javascript - 分离 javascript 和 html 以获得可读代码

css - 初学者 CSS 问题

javascript - 是否可以将 CSS 应用于字符的一半?

css - 如何在 Bootstrap 中考虑容器高度创建绝对侧边栏菜单?