How to Add Rounded Corners to Table Cells Using CSS?

Linda Hamilton
Release: 2024-10-28 13:42:02
Original
259 people have browsed it

How to Add Rounded Corners to Table Cells Using CSS?

Applying Border Radius to Table Cells

To add rounded corners to table rows (tr), consider the following approach:

  • CSS limitations: Note that you cannot directly apply border-radius to tr or table elements. Instead, you must apply it to individual table cells (td).
  • Separate Border and Padding for Cells:
<code class="css">table {
  border-collapse: separate;
  border-spacing: 0;
}

td {
  border: solid 1px #000;
  border-style: none solid solid none;
  padding: 10px;
}</code>
Copy after login
  • Corner Styles:
<code class="css">tr:first-child td:first-child { border-top-left-radius: 10px; }
tr:first-child td:last-child { border-top-right-radius: 10px; }

tr:last-child td:first-child { border-bottom-left-radius: 10px; }
tr:last-child td:last-child { border-bottom-right-radius: 10px; }</code>
Copy after login
  • Border Styles for Top and Left Cells:
<code class="css">tr:first-child td { border-top-style: solid; }
tr td:first-child { border-left-style: solid; }</code>
Copy after login

This technique allows for the creation of rounded corners on the table while maintaining the desired border and spacing.

The above is the detailed content of How to Add Rounded Corners to Table Cells Using CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!