Home > Article > Web Front-end > How to Make Links the Same Height as Table Rows?
Make the Link the Same Height of the Table Row
In table formatting, links may be placed within each cell to facilitate user interaction. However, when the content of the cells varies in height, the links may not fill the entire vertical space of the row, leading to an undesirable appearance.
To resolve this issue, the CSS styling of the table cells and their link elements can be modified:
1. Implement Display: Block:
<code class="css">td a { display: block; }</code>
2. Set Negative Margin and Equal Padding:
To account for cells with multiple lines, set a large negative margin and equal padding on the block element. This forces the link to expand and fill the entire space.
<code class="css">td a { ... margin: -10em; padding: 10em; }</code>
3. Prevent Overflow:
To ensure that the overflowing content is hidden, add the following to the parent element:
<code class="css">td { overflow: hidden; }</code>
An example demonstrating this technique:
<code class="css">td { overflow: hidden; } td a { display: block; margin: -10em; padding: 10em; }</code>
With these adjustments, the links will now fill the entire height of the table row, providing a more uniform and interactive user experience.
The above is the detailed content of How to Make Links the Same Height as Table Rows?. For more information, please follow other related articles on the PHP Chinese website!