css - 如何制作水平线?

标签 css line

你好,这是我想做的,

http://i1377.photobucket.com/albums/ah45/nikilean/line_zpswvrndxwg.jpg

图像后面的水平线?有8个圆圈,我想用一条线把它们连起来

我是在 bootstrap 中创建的,所以这些行分为两个 col 6,每个 col 里面有 3 个 col-3

 .stepnumber {
  height: 30px;
  width: 30px;
  border-radius: 50%;
  background-color: #f9b315;
  vertical-align: middle;
  color: #fff;
  padding-top: 2px;
  padding-right: 10px;
  font-size: 18px;
  font-weight: bold;
  margin-top: 150px;
  left: -10px;

}

.step {
  height: 150px;
  width: 150px;
  border-radius: 50%;
  background-color: #fff;
  margin-top: 80px;
  margin-right:-60px;
  position: absolute;

}





<div class="container">
          <div class="col-md-6">
                <div class="row">
                    <div class="col-md-3">
                      <div class="lineline"><div class=stepnumber>1</div></div>
                    </div>
                    <div class="col-md-3">
                     <div class="step">
                        <div class="workstitle">
                          BOOK
                        </div>

                </div>           
                    </div>
                    <div class="col-md-3">
                      <div class=stepnumber>2</div>
                    </div>
                    <div class="col-md-3">
                      <div class="step">
                        <div class="workstitle">
                          WAIT
                        </div>

                      </div>          
                    </div>
                 </div>
              </div> 

    <div class="col-md-6">
            <div class="row">
                <div class="col-md-3">
                  <div class=stepnumber>3 </div> 
                </div>
                <div class="col-md-3">
                  <div class="step">
                   <div class="workstitle">
                     FOUND
                   </div> 

            </div>          
                </div>
                <div class="col-md-3">
                  <div class=stepnumber>4</div>
                </div>
                <div class="col-md-3">
                  <div class="step">
                   <div class="workstitle">
                     FLY!
                   </div> 

            </div>          
                </div>
          </div>
    </div>
</div>

最佳答案

您可以通过在包装元素上使用 :after(或 :before)伪类来实现您想要的外观。您可以在 :after 元素上创建一个边框,并使用 z-index 将其放置在您的圆圈后面。

下面是如何构建它的示例。

.timeline {
  height: 150px;
  line-height: 150px;
  display: table;
  position: relative;
}
.timeline:after {
  position: absolute;
  left: 0.5em;
  right: 0.5em;
  top: 50%;
  content: "";
  border-top: 3px solid #F9B315;
  z-index: 900;
}
.-item {
  display: table-cell;
  vertical-align: middle;
  z-index: 1000;
  position: relative;
}
.-item > div {
  margin-left: 0.5em;
  margin-right: 0.5em;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  text-align: center;
  line-height: 150px;
  font-weight: bold;
  font-size: 18px;
  background-color: #f9b315;
  color: #FFF;
}
.-item:first-of-type > div { margin-left: 0; }
.-item:last-of-type > div { margin-right: 0; }
.-item._number > div {
  width: 30px;
  height: 30px;
  line-height: 2;
}
<div class="timeline">
  <div class="-item _number">
    <div>1</div>
  </div>
  <div class="-item _title">
    <div>BOOK</div>
  </div>
  <div class="-item _number">
    <div>2</div>
  </div>
  <div class="-item _title">
    <div>WAIT</div>
  </div>
  <div class="-item _number">
    <div>3</div>
  </div>
  <div class="-item _title">
    <div>FOUND</div>
  </div>
  <div class="-item _number">
    <div>4</div>
  </div>
  <div class="-item _title">
    <div>FLY!</div>
  </div>
</div>

关于css - 如何制作水平线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28891408/

相关文章:

html - 如何将两个图像对齐在 HTML 的中心,彼此重叠?

html - 保持div中的信息始终以特定行数显示

css - 如何将容器 <div> 的 2 个 float <div> 元素彼此相邻放置?

javascript - 如何将倒数计时器添加到我的页面

html - 将 div 对齐到顶部

gnuplot - 如何使网格虚线相交,在 gnuplot 中制作十字线?

bash - 获取物理键盘布局

javascript - 如何根据 C3.js/D3.js 图表中的阈值更改线条颜色?

bash - 修改文件中一行的一部分

javascript - 如何在 jquery 选项卡中为 td 添加事件类?