I’m struggling to get my table data to be directly underneath my table headers it’s currently looking like this on inspection:
enter image description here
this is what it looks like with a space around , but how can I make it more centered?
2
I give you an example for your reference:
/* DivTable.com */ .divTable { display: table; width: 100%; } .divTableRow { display: table-row; } .divTableHeading { background-color: #EEE; display: table-header-group; } .divTableCell, .divTableHead { border: 1px solid #999999; display: table-cell; padding: 3px 10px; } .divTableHeading { background-color: #EEE; display: table-header-group; font-weight: bold; } .divTableFoot { background-color: #EEE; display: table-footer-group; font-weight: bold; } .divTableBody { display: table-row-group; }
<div class="divTable"> <div class="divTableBody"> <div class="divTableRow"> <div class="divTableCell"> cxvv</div> <div class="divTableCell"> xcvxcv</div> <div class="divTableCell"> xcvx</div> </div> <div class="divTableRow"> <div class="divTableCell"> vxvx</div> <div class="divTableCell"> wewrwe</div> <div class="divTableCell"> xcvxv</div> </div> <div class="divTableRow"> <div class="divTableCell"> xxcvxcv</div> <div class="divTableCell"> dsf</div> <div class="divTableCell"> sdf</div> </div> <div class="divTableRow"> <div class="divTableCell"> vfsdf</div> <div class="divTableCell"> sdfsf</div> <div class="divTableCell"> dsfsdf</div> </div> <div class="divTableRow"> <div class="divTableCell"> cxvxcv</div> <div class="divTableCell"> sdfsf</div> <div class="divTableCell"> sdf</div> </div> </div> </div>
You can browse the web site to generate the div table.
This is a pure flexbox example:
.cell, .cellEnd, .cellTail, .container, .headerRow, .row { display: flex; flex-grow: 1; } .cell, .cellEnd, .cellTail { border-top: 1px solid black; border-left: 1px solid black; } .cellBottom { border-bottom: 1px solid black; } .cellEnd { border-bottom: 1px solid black; } .cellEnd, .cellTail { border-right: 1px solid black; } .container { flex-direction: column; } .headerRow .cell, .headerRow .cellTail { font-weight: bold; justify-content: center; } .row .cell, .row .cellEnd { padding: 3px; }
<div class="container"> <div class="headerRow"> <div class="cell"> 1 </div> <div class="cell"> 2 </div> <div class="cellTail"> 3 </div> </div> <div class="row"> <div class="cell cellBottom"> 1000 </div> <div class="cell cellBottom"> 2000 </div> <div class="cellEnd"> 3000 </div> </div> </div>
Click here to cancel reply.
2
Answers
I give you an example for your reference:
You can browse the web site to generate the div table.
This is a pure flexbox example: