如何制作水平线?

时间:2015-03-06 02:27:46

标签: css line

嗨,所以这就是我想做的事,

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

图像背后的水平线?有8个圆圈,我希望它们用一条线连接

我在引导程序中创建它,因此行分为两个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>

2 个答案:

答案 0 :(得分:0)

您可以通过在包装元素上使用: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>

答案 1 :(得分:0)

这对你来说需要做一些工作,但这里有一种方法可以在div后面加一条水平线。

Here is the fiddle.该线的诀窍是制作一个仅高1px的div。您需要一点思考:

.line{
  height: 1px;
  width: 100px;
  background-color: black;
  z-index: 1;
  position: absolute;
  top: 25px;
}