Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS border - just part of the line

Tags:

css

Is there a way how to use css (ideal) to draw element border but just a part of the line (in the image below left and right border)?

enter image description here

like image 452
Petr Avatar asked Oct 09 '15 21:10

Petr


2 Answers

Yes, you can, like this, and even IE8 can do this:

div {
    position: relative;
    width: 100px;
    padding: 10px;
}
div:before {
    content: " ";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    border: 1px solid black;
    border-top-width: 0;
}
<div>Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello </div>
like image 120
Asons Avatar answered Oct 04 '22 10:10

Asons


Please try this:

.box {
  position: relative;
  min-height: 100px;
  padding-bottom: 10px;
}
.box .text {
  margin: 10px;
}
.box .bordered {
  position: absolute;
  bottom: 0;
  height: 30%;
  border-right: 1px solid #000;
  border-left: 1px solid #000;
  border-bottom: 1px solid #000;
  width: 100%;
  z-index: 1000;
}

<div class="box">    
    <div class="text">Hell world!</div>
    <div class="bordered"></div>
</div>

see the fiddle here: https://jsfiddle.net/42zgo5aa/3/

like image 20
John Diaz Avatar answered Oct 04 '22 10:10

John Diaz