Here are two possible ways to do this:
Mandatory HTML will remain unchanged in both methods and will look like this:
HTML:
<div class="box"></div>
Method # 01:
- Draw the top, right, and left borders using the
border css property. - Draw the bottom transparent border using the
linear-gradient css property.
CSS
.box { background: linear-gradient(to right, #000 30%, transparent 30%, transparent 70%, black 70%) no-repeat; background-size: 100% 8px; background-position: 0 100%; border: solid #000; border-width: 8px 8px 0; width: 100px; height: 50px; }
html, body { height: 100%; } body { background: linear-gradient(to top, #ff5a00 0, #ffae00 100%); margin: 0; } .box { background: linear-gradient(to right, #000 30%, transparent 30%, transparent 70%, black 70%) no-repeat; background-size: 100% 8px; background-position: 0 100%; border: solid #000; border-width: 8px 8px 0; margin: 20px 15px; width: 100px; height: 50px; }
<div class="box"></div>
Method # 02:
- Draw the top, left and right borders with the property
border the css. - Draw the bottom borders with
:before and :after pseudo-elements.
CSS
.box { border: solid black; border-width: 8px 8px 0; position: relative; overflow: hidden; width: 100px; height: 50px; } .box:before, .box:after { position: absolute; background: #000; content: ''; height: 8px; width: 30%; bottom: 0; left: 0; } .box:after { left: auto; right: 0; }
html, body { height: 100%; } body { background: linear-gradient(to top, #ff5a00 0, #ffae00 100%); margin: 0; } .box { border: solid black; border-width: 8px 8px 0; position: relative; overflow: hidden; margin: 15px 10px; width: 100px; height: 50px; } .box:before, .box:after { position: absolute; background: #000; content: ''; height: 8px; width: 30%; bottom: 0; left: 0; } .box:after { left: auto; right: 0; }
<div class="box"></div>
source share