Instead of the usual vertical table data layout something like this:
I'd like to display it like this in css:
Any ideas?
My php/html code:
<div class="center_div">
<table>
<tr>
<th>Author</th>
<th>Quotes</th>
<th>Arabic</th>
<th>Reference</th>
</tr>
<?php while ($row= mysql_fetch_array($result)) { ?>
<tr>
<td width="150"><?php h($row['vAuthor']) ?></td>
<td><?php h($row['cQuotes']) ?></td>
<td><?php h($row['cArabic']) ?></td>
<td><?php h($row['vReference']) ?></td>
</tr>
<?php } ?>
</table>
</div></div>
To make the horizontal bordered table, we will add the “pure-table-horizontal” class. Pure CSS Table with Horizontal Borders Class: pure-table-horizontal: This class is used to create the horizontal bordered table. This class is used with a pure-table class.
It is possible to change the horizontal alignment of items within table cells. Table data defaults to left alignment; table headers to center. In order to change the alignment in one cell, insert the appropriate "ALIGN=" attribute within the code for that cell.
Use the margin Property to Center a div Horizontally in CSS We can use the auto option for the left and the right margin to horizontally center a div . The top and bottom margin can be set to 0 . The auto option will place the element in the center and divide equally divide the left and right margin.
To make table width bigger you can apply some CSS for StackTrace column. If you need to display it in one line - use white-space: nowrap; If you need only some specific width for it - use min-width: #px or just width: #px; To align all elements to top of cell use vertical-align: top .
You can do this and it'll still be semantic:
<table>
<tr>
<th>Header</th>
<td>content</td>
<td>content</td>
<td>content</td>
</tr>
</table>
Example from w3schools:
table {
width: 100%
}
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
th,
td {
padding: 5px;
text-align: left;
}
<h2>Horizontal Headings:</h2>
<table>
<tr>
<th>Name</th>
<th>Telephone</th>
<th>Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
<h2>Vertical Headings:</h2>
<table>
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 77 854</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 77 855</td>
</tr>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With