Use CSS padding to design the distance between HTML table borders and fields
Using CSS padding to design the distance between the HTML table border and the field is a form design technique. It can increase the distance between the table border and the field border in the table. Of course, it can also reduce the distance between each other. It is similar to traditional HTML tables . Cellspacing attribute, but the effect of using CSS padding is more delicate, and does not affect the distance between the table fields, and simply controls the distance between the table's own border and the internal field. The following examples let you see clearly, almost all mainstream Browsers all support this padding effect.
The distance between the HTML table border and the field example 1. The four borders are the same distance from the field
<!--
table{
padding:10px;
background-color:#eee;
border:1px solid black;
}
td{
border:1px solid black;
background-color:white;
}
- ->
</style>
<table>
<tr><td>Example table fields</td><td>Example table fields</td></tr>
<tr><td>Example table fields</td> td><td>Sample table fields</td></tr>
</table>
Example table field | Example table field |
Example table field | Example table field |
- CSS padding properties and usage examples
- CSS background-color background color
Example of the distance between the HTML table border and the field 2. The difference between the top and bottom borders and the left and right borders of the table
<!--
table{
padding:10px 2px;
background-color:#eee;
border:1px solid black;
}
td{
border:1px solid black;
background-color:white;
}
-->
</style>
<table>
<tr><td>Example table field</td><td>Example table field</td></tr>
<tr><td>Example table field< /td><td>Sample table fields</td></tr>
</table>
Example table field | Example table field |
Example table field | Example table field |
PS. Please copy the code of example 1 and example 2 to a blank document and save it as test.html, open the file with a browser, you can see the effect, you can modify the parameter value of padding or the background color. Change the style of the table.
Post a Comment
0 Comments