I want to achieve that all the div that is in table values should be of the same height in short the height of all the div should be of the same height inside the table values
I have tried some solutions but didn’t work for me.
As shown in the image the first line item is the tallest so all the other have the height of the tallest one
.section-4 {
width: 100%;
border: 1px solid #000;
border-top: 0;
}
.section-4 .table .table-header {
display: flex;
text-align: center;
vertical-align: middle;
}
.section-4 .table .sr_no,
.section-4 .table .unit {
border-right: 1px solid black;
width: 3%;
}
.section-4 .table .unit {
width: 5%;
}
.section-4 .table .qty {
border-right: 1px solid black;
width: 8.3%;
}
.section-4 .table .des_of_goods {
border-right: 1px solid black;
width: 49%;
}
.section-4 .table .table-values .des_of_goods .content {
padding: 0 2px;
}
.section-4 .table .rate,
.section-4 .table .disc,
.section-4 .table .tax-amt,
.section-4 .table .disc-amt {
border-right: 1px solid black;
width: 8.75%;
}
.section-4 .table .tax-amt {
border-right: 0;
}
.section-4 .table .table-values {
display: flex;
/* flex-flow: row wrap; */
/* align-items: stretch; */
}
.section-4 .table .table-values .table-cell {
border-top: 1px solid black;
/* height: 100%; */
flex-grow: 1;
}
.section-4 .table .table-values .table-cell:not(:nth-child(2)) {
display: flex;
align-items: center;
justify-content: center;
}
.section-4 .table .table-values .table-cell .add-info,
.section-4 .table .table-values .table-cell .order-info {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.section-4 .table .table-values .table-cell .add-info {
/* margin-top: 5px; */
}
.section-4 .table .table-values .table-cell .des_of_goods .content {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.section-4 .table .table-values .table-cell .add-info p {
white-space: nowrap;
}
<section class="section-4">
<div class="table">
<div class="table-header">
<div class="sr_no">
<p><strong>SR No.</strong></p>
</div>
<div class="des_of_goods">
<p><strong>Description of Goods</strong></p>
</div>
<div class="qty">
<p><strong>Qty</strong></p>
</div>
<div class="unit">
<p><strong>Unit</strong></p>
</div>
<div class="rate">
<p><strong>Rate</strong></p>
</div>
<div class="disc">
<p><strong>Disc. %</strong></p>
</div>
<div class="disc-amt">
<p><strong>Discount Amount</strong></p>
</div>
<div class="tax-amt">
<p><strong>Taxable Amount</strong></p>
</div>
</div>
<div class="table-values">
<div class="table-cell sr_no text-center">
<p><strong>2</strong></p>
</div>
<div class="table-cell des_of_goods">
<div class="content">
<p><strong>TR45A/NS/5aSSHJLJ4- I : TR-45A : HEATSET : HEAT
SET R-45A HEATSET bLUE TR45A/NS/5aSSHJLJ4- I : TR-45A : HEATSET : HEAT
SET R-45A HEATSET bLUE</strong></p>
<div class="add-info">
<p>HSN : 6004100 </p>
<p>Width: 60 ( inch ) </p>
<p>Buyer Ref: VO240052 </p>
</div>
<div class="order-info">
<p>Order no: SRFSO2425- 00429 </p>
<p>Challan/Packing no: SRFSD2425- 03410</p>
</div>
</div>
</div>
<div class="table-cell qty text-center">
<p>21,232.00</p>
</div>
<div class="table-cell unit text-center">
<p>Mtr.</p>
</div>
<div class="table-cell rate text-center">
<p>9,610.80</p>
</div>
<div class="table-cell disc text-center">
<p>100.00</p>
</div>
<div class="table-cell disc-amt text-center">
<p>10,000.00</p>
</div>
<div class="table-cell tax-amt text-center">
<p>30,77,002.00</p>
</div>
</div>
<div class="table-values">
<div class="table-cell sr_no text-center">
<p><strong>2</strong></p>
</div>
<div class="table-cell des_of_goods">
<div class="content">
<p><strong>TR45A/NS/5aSSHJLJ4- I : TR-45A : HEATSET : HEAT
SET R-45A HEATSET bLUE</strong></p>
<div class="add-info">
<p>HSN : 6004100 </p>
<p>Width: 60 ( inch ) </p>
<p>Buyer Ref: VO240052 </p>
</div>
<div class="order-info">
<p>Order no: SRFSO2425- 00429 </p>
<p>Challan/Packing no: SRFSD2425- 03410</p>
</div>
</div>
</div>
<div class="table-cell qty text-center">
<p>21,232.00</p>
</div>
<div class="table-cell unit text-center">
<p>Mtr.</p>
</div>
<div class="table-cell rate text-center">
<p>9,610.80</p>
</div>
<div class="table-cell disc text-center">
<p>100.00</p>
</div>
<div class="table-cell disc-amt text-center">
<p>10,000.00</p>
</div>
<div class="table-cell tax-amt text-center">
<p>30,77,002.00</p>
</div>
</div>
<div class="table-values">
<div class="table-cell sr_no text-center">
<p><strong>2</strong></p>
</div>
<div class="table-cell des_of_goods">
<div class="content">
<p><strong>TR45A/NS/5aSSHJLJ4- I : TR-45A : HEATSET : HEAT
SET R-45A HEATSET bLUE</strong></p>
<div class="add-info">
<p>HSN : 6004100 </p>
<p>Width: 60 ( inch ) </p>
<p>Buyer Ref: VO240052 </p>
</div>
<div class="order-info">
<p>Order no: SRFSO2425- 00429 </p>
<p>Challan/Packing no: SRFSD2425- 03410</p>
</div>
</div>
</div>
<div class="table-cell qty text-center">
<p>21,232.00</p>
</div>
<div class="table-cell unit text-center">
<p>Mtr.</p>
</div>
<div class="table-cell rate text-center">
<p>9,610.80</p>
</div>
<div class="table-cell disc text-center">
<p>100.00</p>
</div>
<div class="table-cell disc-amt text-center">
<p>10,000.00</p>
</div>
<div class="table-cell tax-amt text-center">
<p>30,77,002.00</p>
</div>
</div>
</div>
</section>
3
Answers
want to achieve this using div as for fixed width using flexbox to achieve the tallest height of the div to all others
For your example – which is not an actual table and therefore suffers from columns not having the right width – you could use
grid
withgrid-auto-rows: 1fr;
This is how it would look like if applied to your setup: the only thing changed for HTML is that all your
table-values
are wrapped in onediv
. (It still suffers from your original problem that the columns of the different rows don’t line up correctly if the window is too small, but that can only be solved if you use something different thenflex
).If you can use
subgrid
, you could usetable
, which would also have semantic meaning or any HTML structure you want like yours. You might need to adapt the CSS a bit; right now is a of a proof of concept and probably does not fully reflect what you need:There are multiple ways we can perform it,
For css Flexbox u can refer https://www.w3schools.com/css/css3_flexbox.asp
and for
CSS Grid u can refer https://www.w3schools.com/css/css_grid.asp
i would suggest go for flexbox if ur using 1-d designs