溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

css設(shè)置table圓角邊框為什么會不起作用

發(fā)布時間:2020-11-30 12:56:40 來源:億速云 閱讀:750 作者:小新 欄目:web開發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)css設(shè)置table圓角邊框為什么會不起作用,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

css設(shè)置table圓角邊框不起作用的原因是:屬性border-collapse:collapse和屬性border-radius不兼容。正確方法如【border-collapse: separate;border-spacing:0】。

原因分析:

在table中設(shè)置border-radius發(fā)現(xiàn)不起作用,原因是border-collapse:collapse和border-radius不兼容。

css:

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

代碼實現(xiàn):

<!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 {/*設(shè)置table左邊邊框*/
border-left: 2px solid #eaeaea;
}
table tr th:last-child,table tr td:last-child {/*設(shè)置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{/*設(shè)置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{/!*設(shè)置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內(nèi)容1</td>
<td>1內(nèi)容2</td>
<td>1內(nèi)容3</td>
<td>1內(nèi)容4</td>
</tr>
<tr>
<td>2內(nèi)容1</td>
<td>2內(nèi)容2</td>
<td>2內(nèi)容3</td>
<td>2內(nèi)容4</td>
</tr>
<tr>
<td>3內(nèi)容1</td>
<td>3內(nèi)容2</td>
<td>3內(nèi)容3</td>
<td>3內(nèi)容4</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

實現(xiàn)效果:

css設(shè)置table圓角邊框為什么會不起作用

關(guān)于css設(shè)置table圓角邊框為什么會不起作用就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI