Equal Width Table Cells with Variable Content
Consider a scenario where you have multiple table-cell elements inside a table container. Despite having different content sizes, you want these table-cells to have equal widths. Is there a purely CSS solution to achieve this?
Solution:
To achieve equal-width table-cells regardless of content size, you can utilize the following CSS approach:
Code Example:
<code class="css">div { display: table; width: 250px; table-layout: fixed; } div > div { display: table-cell; width: 2%; }</code>
Note:
This solution works with Chrome, IE8, and Safari 6 (with some caveats). However, it's important to remember that Safari 6 may have different table layout behaviors compared to other browsers.
The above is the detailed content of Can you create equal width table cells with varying content using purely CSS?. For more information, please follow other related articles on the PHP Chinese website!