这是我的CSS
.dashboard th {
background-color: green;
border: 0px solid green;
white-space: nowrap;
color: black;
text-align: left;
}
为什么边框没有变色?
答案 0 :(得分:1)
您可以将border-collapse
属性添加到表格中以使边框变小:
.dashboard{
border-collapse: collapse;
}
.dashboard th {
background-color: green;
border: 0px solid green;
white-space: nowrap;
color: black;
text-align: left;
}
<table class="dashboard">
<tr>
<th>Should be green border</th>
<th>Should be green border</th>
<th>Should be green border</th>
</tr>
</table>
您可以指定自己的边框宽度:
.dashboard {
border-collapse: collapse;
}
.dashboard th {
background-color: green;
border: 5px solid red; /* Just for demo */
white-space: nowrap;
color: black;
text-align: left;
}
<table class="dashboard">
<tr>
<th>Should be green border</th>
<th>Should be green border</th>
<th>Should be green border</th>
</tr>
</table>
答案 1 :(得分:1)
您的问题有两点:
name:ABC~1 AND name:BLOSSOMING~1 AND name:COMPANY~1
,它将无法获得颜色。border:0
来消除快照中出现的空白。
我认为以下修复方法可以完成这项工作:
border-collapse: collapse;
table.dashboard {
border-collapse: collapse;
border: 1px solid green;
background: #fff;
}
table.dashboard td {
border: 1px solid #bbb;
}
table.dashboard th {
background-color: green;
border: 1px solid black;
white-space: nowrap;
color: black;
text-align: left;
}
/* just to tidy the page, not part of the answer ;) */
body {
margin: 0;
padding: 0;
background: #f2f2f2;
}
.container {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
答案 2 :(得分:0)
更改边框: style =“ border:0px;” 绿色;边框: 1px 纯绿色;或者您想根据需要增加像素。
.dashboard th {
background-color: green;
border: 1px solid green;
white-space: nowrap;
color: black;
text-align: left;
}