Any way to declare a size/partial border to a box?

davidmatas picture davidmatas · Jan 12, 2012 · Viewed 54.5k times · Source

Any way to declare a size/partial border to a box in CSS? For example a box with 350px that only shows a border-bottom in its firsts 60px. I think that might be very useful.

Examples:

enter image description here enter image description here

Answer

bookcasey picture bookcasey · Jan 12, 2012

Not really. But it's very easy to achieve the effect in a way that degrades gracefully and requires no superfluous markup:

div {
  width: 350px;
  height: 100px;
  background: lightgray;
  position: relative;
  margin: 20px;
}

div:after {
  content: '';
  width: 60px;
  height: 4px;
  background: gray;
  position: absolute;
  bottom: -4px;
}
<div></div>