Push border-bottom from left and right with some pixels

975 views Asked by At

I would like to know, if it is possible to give to a border-bottom something like a padding-left and padding-right. I have two divs, which have some borders. I would like to make the border-bottom of the top div to have some padding on left and right. I have no idea if this is possible. I know the structure is strange (I could easy use the border around the whole box wrapper and than work on the span with a border-bottom to achieve this). The problem is, I'm using a plugin which has a structure like this and I have to customize it like this, because there is exactly this strucure and styling. Hope it's clear enough. Here a picture how it should look and an example snippet:

enter image description here

.box {
  display: flex;
  flex-direction: column;
  width: 200px;
}

.box__top {
  border: 1px solid black;
  border-bottom: 1px solid red;
  height: 20px;
  padding: 10px;
  text-align: center;
}

.box__bottom {
  border: 1px solid black;
  border-top: none;
  height: 150px;
  padding: 10px;
  text-align: center;
}
<div class="box">
  <div class="box__top">
    <span>I'm the top section</span>
  </div>
  <div class="box__bottom">
    <span>I'm the top section</span>
  </div>
</div>

1

There are 1 answers

0
Paulie_D On BEST ANSWER

Use a pseudo-element instead:

.box {
  display: flex;
  flex-direction: column;
  width: 200px;
}

.box__top {
  border: 1px solid black;
  border-bottom: none;
  position: relative;
  height: 20px;
  padding: 10px;
  text-align: center;
}

.box__top::after {
  content: " ";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 90%;
  height: 1px;
  background-color: red;
}

.box__bottom {
  border: 1px solid black;
  border-top: none;
  height: 150px;
  padding: 10px;
  text-align: center;
}
<div class="box">
  <div class="box__top">
    <span>I'm the top section</span>
  </div>
  <div class="box__bottom">
    <span>I'm the top section</span>
  </div>
</div>