Is it possible to add border to col inside separate row using bootstrap

486 views Asked by At

I am using bootstrap's ROW and COL to make a food menu, im not sure if this is the right way to do this because i get gaps between rows.

how it should look like:

but i get this:

As you can see there is a horrible gap between the rows

my code: jsFiddle HTML

<div class="row">
    <div class="col-9">
        <h3 class="menu-dish">Chateau D'Armailhac Rothschild Pauillac 5-Eme G.C.C.</h3>France
    </div>
    <div class="col-3">
        <div class="row">
            <div class="col-6 price">
                123 usd
            </div>
            <div class="col-6 price">
                123 usd
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-9">
        <h3 class="menu-dish">Chateau D'Armailhac Rothschild Pauillac 5-Eme G.C.C.</h3>France
    </div>
    <div class="col-3">
        <div class="row">
            <div class="col-6 price">
                123 usd
            </div>
            <div class="col-6 price">
                123 usd
            </div>
        </div>
    </div>
</div>

CSS

.price {
  border-left: 1px solid black;
  border-right: 1px solid black;
}
.price:first-child{
  border-left:none;
}
.price:last-child{
  border-right:none;
}
2

There are 2 answers

1
לבני מלכה On BEST ANSWER

Use h-100 to nested row

See sizing in bootstrap-4:https://www.w3schools.com/bootstrap4/bootstrap_utilities.asp

.price {
  border-left: 1px solid black;
  border-right: 1px solid black;
}
.price:first-child{
  border-left:none;
}
.price:last-child{
  border-right:none;
}
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="row">
 <div class="col-9">
  <h3 class="menu-dish">Chateau D'Armailhac Rothschild Pauillac 5-Eme G.C.C.</h3>France
 </div>
 <div class="col-3">
  <div class="row h-100">
   <div class="col-6 price">
    123 usd
   </div>
   <div class="col-6 price">
    123 usd
   </div>
  </div>
 </div>
</div>
<div class="row">
 <div class="col-9">
  <h3 class="menu-dish">Chateau D'Armailhac Rothschild Pauillac 5-Eme G.C.C.</h3>France
 </div>
 <div class="col-3">
  <div class="row h-100">
   <div class="col-6 price">
    123 usd
   </div>
   <div class="col-6 price">
    123 usd
   </div>
  </div>
 </div>
</div>

0
Silu K On

I just added 100% height to row which is inside col, Hope you were looking for this. Let me know.

http://jsfiddle.net/sarojuid/uo92x6yt/

.row {
    min-height:100%;
}