ホームページ  >  記事  >  ウェブフロントエンド  >  CSS設定テーブルの角丸枠が機能しないのはなぜですか?

CSS設定テーブルの角丸枠が機能しないのはなぜですか?

王林
王林オリジナル
2020-11-27 11:47:094660ブラウズ

CSS でテーブルの丸い境界線を設定することが機能しない理由は、プロパティ border-collapse:collapse とプロパティ border-radius に互換性がないためです。正しい方法は [border-collapse: Separate;border-spacing:0] です。

CSS設定テーブルの角丸枠が機能しないのはなぜですか?

#この記事の環境: Windows10、css3、この記事はすべてのブランドのコンピューターに適用されます。

原因分析:

テーブルに border-radius を設定しても、border-collapse:collapse と border-radius に互換性がないことが原因で機能しないことがわかりました。

(学習ビデオ共有:

css ビデオ チュートリアル)

css:

border-collapse: separate;
border-spacing: 0;

コード実装:


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#table_wrap > table {
font-size: 16px;
text-align: center;
margin: 0 auto;
border-collapse: separate;
border-spacing: 0;
border: 2px #000;
}
table thead tr,table tbody tr {
height: 50px;
line-height: 50px;
/*background-color: pink;*/
}
table tr th:first-child,table tr td:first-child {/*设置table左边边框*/
border-left: 2px solid #eaeaea;
}
table tr th:last-child,table tr td:last-child {/*设置table右边边框*/
border-right: 2px solid #eaeaea;
}
table tr td:first-child,
table tr td:nth-child(2),
table tr td:nth-child(3),
table tr td:last-child{/*设置table表格每列底部边框*/
border-bottom: 2px solid #eaeaea;
}
/*table tr:last-child td:first-child,
table tr:last-child td:nth-child(2),
table tr:last-child td:nth-child(3),
table tr:last-child td:last-child{/!*设置table表格最后一列底部边框*!/
border-bottom: 2px solid #000;
}*/
table tr th {
background: #eaeaea;
}
table tr:first-child th:first-child {
border-top-left-radius: 12px;
}
table tr:first-child th:last-child {
border-top-right-radius: 12px;
}
table tr:last-child td:first-child {
border-bottom-left-radius: 12px;
}
table tr:last-child td:last-child {
border-bottom-right-radius: 12px;
}
</style>
</head>
<body>
<div id="table_wrap">
<table width="800" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>头部1</th>
<th>头部2</th>
<th>头部3</th>
<th>头部4</th>
</tr>
</thead>
<tbody>
<tr>
<td>1内容1</td>
<td>1内容2</td>
<td>1内容3</td>
<td>1内容4</td>
</tr>
<tr>
<td>2内容1</td>
<td>2内容2</td>
<td>2内容3</td>
<td>2内容4</td>
</tr>
<tr>
<td>3内容1</td>
<td>3内容2</td>
<td>3内容3</td>
<td>3内容4</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

implementation効果:

CSS設定テーブルの角丸枠が機能しないのはなぜですか?

関連する推奨事項:

CSS チュートリアル

以上がCSS設定テーブルの角丸枠が機能しないのはなぜですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。