Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Divide 3 divs in 3 columns without using float and flex

Tags:

html

css

I tried by using display inline-block to achieve 3 columns but 3rd column comes at separate row:

.wrapper {
   width: 100%;
}
.column {
    display: inline-block;
    min-height: 150px;
    width: 33.33%;
    border: 1px solid black;
    min-width: 300px;
    margin-bottom: 8px;
}
<div class="wrapper">
  <div class="column">abc</div>
  <div class="column">def</div>
  <div class="column">ghi</div>
</div>

Not able to figure out the reason.

like image 696
Tushar Khanna Avatar asked Oct 17 '22 08:10

Tushar Khanna


1 Answers

I dont know this is exactly what you need , i have remove the default whitespace of the inline-block using font-size:0 and add box-size property you dont need to change the width 33.3% to 33% the width please check the snippet

 .wrapper {
  width: 100%;
  font-size: 0;
}
.column {
  display: inline-block;
  min-height: 150px;
  width: 33.33%;
  border: 1px solid black;
  margin-bottom: 8px;
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -ms-box-sizing: border-box;
  -moz-box-sizing: border-box;
}
<div class="wrapper">
  <div class="column">abc</div>
  <div class="column">def</div>
  <div class="column">ghi</div>
</div>
like image 99
Jishnu V S Avatar answered Oct 30 '22 19:10

Jishnu V S