mcbeav mcbeav - 4 months ago 44
CSS Question

Any way to limit border length?

Is there any way to limit the length of a border. I have a

<div>
that has a bottom border, but I want to add a border on the left of the
<div>
that only stretches half of the way up.

Is there any way to do so without adding extra elements on the page?

Answer

Hope this helps:

#mainDiv {
  height: 100px;
  width: 80px;
  position: relative;
  border-bottom: 2px solid #f51c40;
  background: #3beadc;
}

#borderLeft {
  border-left: 2px solid #f51c40;
  position: absolute;
  top: 50%;
  bottom: 0;
}
<div id="mainDiv">
  <div id="borderLeft"></div>
</div>

Comments