Home > Software engineering >  How do I connect two borders in div table
How do I connect two borders in div table

Time:11-22

I am wondering how can I connect the borders between the gaps so it would look like this :

https://imgur.com/a/cW2Qe3Q

I tried to remake it in table instead of div table, but same issue appeared.

As a junior I am going to be happy for any help or advice.

when i tried using a could not still get the result of border-radius in corners and connecting the bottom lines.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100%;
  width: 100vw;
  overflow-x: hidden;
}

.container {
  display: flex;
  justify-content: center;
  margin-top: 5rem;
  flex-direction: column;
}

.vh {
  visibility: hidden;
}

.table {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.table-wrap {
  display: flex;
  align-items: center;
  flex-direction: column;
}

.table__row {
  min-width: 50px;
  margin-right: 1rem;
}

.table__row__top {
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.table p {
  padding: 1rem 2rem;
  border: 1px solid #dadada;
  margin-top: -1px;
  margin-left: -1px;
  height: 55px;
}

.table__desc p {
  padding: 1rem 2rem;
}

.table__btn--black {
  background-color: #000;
}

.table__btns {
  display: flex;
}

.table__btn {
  display: flex;
  justify-content: center;
  padding: 1rem 0.5rem 0.5rem 0.5rem;
}

.table__btn__el {
  width: 100%;
  background-color: #1f48ff;
  border: none;
  border-radius: 5px;
  padding: 1rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  text-align: center;
}

.table__btn__el:hover {
  background-color: #152569;
}

.table__btn__el--black {
  background-color: #000;
}

.table__btn:first-child {
  padding-left: 0;
}

.radius-t-l {
  border-top-left-radius: 5px;
}

.radius-b-l {
  border-bottom-left-radius: 5px;
}

.radius-t-r {
  border-top-right-radius: 5px;
}

.radius-b-r {
  border-bottom-right-radius: 5px;
}
<div >
  <div>
    <div >
      <div >
        <p  aria-hidden="true">empty cell</p>
        <p >Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p >Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
      </div>
      <div >
        <p >company</p>
        <p>❌</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>✔️</p>
        <p>❌</p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>❌</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>❌</p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>❌</p>
        <p>✔️</p>
        <p >✔️</p>
      </div>

    </div>
    <div >
      <div ><a href="#" >Get Started</a></div>
      <div ><a href="#" >Get Started</a></div>
    </div>
  </div>
</div>

CodePudding user response:

table {
  border-collapse: collapse;
}

td {
  border: solid 1px;
  padding: 0 4px;
}
<table>
    <tr>
      <td>Hi</td>
      <td>Hi</td>
      <td>✔️</td>
      <td></td>
      <td>❌</td>
      <td>✔️</td>
      <td></td>
      <td>❌</td>
      <td>✔️</td>
      <td></td>
      <td>❌</td>
    </tr>
</table>

CodePudding user response:

I've unpacked the SCSS into CSS so it'll work in this post. I've just removed the margin-right from your table_row class then added a div called table_separator. I've styled the children to have a border with the exception of the top one which has no border top.

Also note your table doesn't really scale on small screen sizes.

Best wishes

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100%;
  width: 100vw;
  overflow-x: hidden;
}

.container {
  display: flex;
  justify-content: center;
  margin-top: 5rem;
  flex-direction: column;
}

.vh {
  visibility: hidden;
}

.table {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.table-wrap {
  display: flex;
  align-items: center;
  flex-direction: column;
}

.table__row {
  min-width: 50px;
  /* margin-right: 1rem; removed this */
}

.table__row__top {
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.table p {
  padding: 1rem 2rem;
  border: 1px solid #dadada;
  margin-top: -1px;
  margin-left: -1px;
  height: 55px;
}

.table__desc p {
  padding: 1rem 2rem;
}

.table__btn--black {
  background-color: #000;
}

.table__btns {
  display: flex;
}

.table__btn {
  display: flex;
  justify-content: center;
  padding: 1rem 0.5rem 0.5rem 0.5rem;
}

.table__btn__el {
  width: 100%;
  background-color: #1f48ff;
  border: none;
  border-radius: 5px;
  padding: 1rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  text-align: center;
}

.table__btn__el:hover {
  background-color: #152569;
}

.table__btn__el--black {
  background-color: #000;
}

.table__btn:first-child {
  padding-left: 0;
}


/*added block */

.table__separator p {
  width: 1rem;
  padding: 0;
}

.table__separator p:first-child {
  border-top-style: none;
}


/*end of added block */

.radius-t-l {
  border-top-left-radius: 5px;
}

.radius-b-l {
  border-bottom-left-radius: 5px;
}

.radius-t-r {
  border-top-right-radius: 5px;
}

.radius-b-r {
  border-bottom-right-radius: 5px;
}
<br>

<div >
  <div>
    <div >
      <div >
        <p  aria-hidden="true">empty cell</p>
        <p >Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
        <p>Lorem ipsum dolor sit amet consectetur </p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
        <p >Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
      </div>
      <!-- added this -->
      <div >
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
      </div>
      <div >
        <p >company</p>
        <p>❌</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>✔️</p>
        <p>❌</p>
      </div>
      <!-- added this -->
      <div >
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>❌</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>❌</p>
      </div>
      <!-- added this -->
      <div >
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>❌</p>
        <p>✔️</p>
        <p >✔️</p>
      </div>

    </div>
    <div >
      <div ><a href="#" >Get Started</a></div>
      <div ><a href="#" >Get Started</a></div>
    </div>
  </div>
</div>

If you were insistent on not putting another bunch of divs and p elements in your markup you could use the ::after pseudo element and absolutely position them to add the lines you see like the code below. Also see the added gap class:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100%;
  width: 100vw;
  overflow-x: hidden;
}

.container {
  display: flex;
  justify-content: center;
  margin-top: 5rem;
  flex-direction: column;
}

.vh {
  visibility: hidden;
}

.table {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.table-wrap {
  display: flex;
  align-items: center;
  flex-direction: column;
}

.table__row {
  min-width: 50px;
  margin-right: 1rem;
}


/* added this block */

.table__row.gap p {
  position: relative;
}

.table__row.gap p::after {
  position: absolute;
  right: -1rem;
  bottom: -1px;
  content: "";
  border-bottom: 1px solid #dadada;
  width: 1rem;
}


/*end of added block */

.table__row__top {
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.table p {
  padding: 1rem 2rem;
  border: 1px solid #dadada;
  margin-top: -1px;
  margin-left: -1px;
  height: 55px;
}

.table__desc p {
  padding: 1rem 2rem;
}

.table__btn--black {
  background-color: #000;
}

.table__btns {
  display: flex;
}

.table__btn {
  display: flex;
  justify-content: center;
  padding: 1rem 0.5rem 0.5rem 0.5rem;
}

.table__btn__el {
  width: 100%;
  background-color: #1f48ff;
  border: none;
  border-radius: 5px;
  padding: 1rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  text-align: center;
}

.table__btn__el:hover {
  background-color: #152569;
}

.table__btn__el--black {
  background-color: #000;
}

.table__btn:first-child {
  padding-left: 0;
}


/*added block */


/*end of added block */

.radius-t-l {
  border-top-left-radius: 5px;
}

.radius-b-l {
  border-bottom-left-radius: 5px;
}

.radius-t-r {
  border-top-right-radius: 5px;
}

.radius-b-r {
  border-bottom-right-radius: 5px;
}
<br>

<div >
  <div>
    <div >
      <div >
        <p  aria-hidden="true">empty cell</p>
        <p >Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
        <p>Lorem ipsum dolor sit amet consectetur </p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere</p>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
        <p >Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, aut.</p>
      </div>
      <div >
        <p >company</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>✔️</p>
      </div>

      <div >
        <p >company</p>
        <p>❌</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>✔️</p>
        <p>❌</p>
      </div>

      <div >
        <p >company</p>
        <p>✔️</p>
        <p>❌</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>❌</p>
      </div>

      <div >
        <p >company</p>
        <p>✔️</p>
        <p>✔️</p>
        <p>❌</p>
        <p>❌</p>
        <p>✔️</p>
        <p >✔️</p>
      </div>

    </div>
    <div >
      <div ><a href="#" >Get Started</a></div>
      <div ><a href="#" >Get Started</a></div>
    </div>
  </div>
</div>

  • Related