CSS中的垂直和水平线

时间:2018-12-20 11:15:19

标签: html css css3

如何使用CSS制作此行(参见图片)?

this

3 个答案:

答案 0 :(得分:2)

pseudo element用作:after

div{
height:80px;
width:3px;
background:black;
border-radius: 23%;
position:relative;
}
div:after{
content:'';
height:3px;
width:170px;
background:black;
border-radius: 23%;
position:absolute;
top:47%;
}
<div></div>

答案 1 :(得分:2)

不需要复杂的代码,一个元素和几行CSS就足够了:

.line {
  width:200px;
  height:100px;
  border-left:5px solid;
  background:linear-gradient(#000,#000) center/100% 5px no-repeat;
}
<div class="line">
</div>

或者这样:

.line {
  width:200px;
  height:100px;
  padding:48px 0;
  box-sizing:border-box;
  border-left:5px solid;
  background:#000 content-box;
}
<div class="line">
</div>

答案 2 :(得分:1)

.line1 {
  height:150px;
  width:3px;
  background:#000;
  position:relative;
}

.line2 {
  height:5px;
  width:300px;
  background:#000;
  position:absolute;
/* following 2 code is excellent center  for second line. */
  top:50%;
  transform:translateY(-50%);
}
<div class="line1">
  <div class="line2"></div>
</div>