我使用具有表css属性的div创建了一个简单的数据表。但是,当我尝试为表格添加圆角边框时,它在Firefox中不起作用。它仅适用于Chrome。还有另一种方法可以像这样添加圆角边界半径吗?
这是我的桌子
* {
box-sizing: border-box;
}
body {
background-color: #efefef;
}
.container {
display: inline-block;
padding: 50px 50px;
min-width: 100%;
}
.datatable-table {
display: table;
padding: 5px;
min-width: 100%;
}
.datatable-rows {
display: table-row;
padding: 5px;
height: 43px;
background-color: #fff;
font-family: Roboto, sans-serif;
line-height: 1.5;
font-size: 14px;
}
.datatable-filters {
display: table-row;
padding: 5px;
height: 43px;
white-space: nowrap;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
color: #7a7a7a;
border-radius: 3px 3px 0px 0px;
padding: 15px 0px;
}
.datatable-header {
display: table-row;
padding: 5px;
height: 43px;
white-space: nowrap;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
color: #7a7a7a;
background: #dedede;
border-radius: 3px 3px 0px 0px;
padding: 15px 0px;
cursor: pointer;
}
.datatable-header .datatable-cell:first-child {
border-radius: 3px 0 0 0;
}
.datatable-header .datatable-cell:last-child {
border-radius: 0 3px 0 0;
}
.datatable-rows .datatable-cell:first-child {
border-radius: 0 0 0 6px;
}
.datatable-rows .datatable-cell:last-child {
border-radius: 0 0 6px 0;
}
.datatable-cell {
display: table-cell;
padding: 0 20px;
width: 150px;
margin: 5px;
vertical-align: middle;
text-align: center;
}
<div class="container">
<div class="datatable-table">
<div class="datatable-filters">
<div class="datatable-cell">
<div style="display: flex; justify-content: space-between;">
<input type="text" value="2019-05-12" style="width: 47%">
<input type="text" value="2019-05-12" style="width: 47%">
</div>
</div>
<div class="datatable-cell">Row 1, Column 2</div>
<div class="datatable-cell">Date added</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
</div>
<!-- datatable-filters -->
<div class="datatable-header">
<div class="datatable-cell">Date added</div>
<div class="datatable-cell">Date changed</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short things</div>
</div>
<!-- datatable-header -->
<div class="datatable-rows">
<div class="datatable-cell">2019-01-01</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
</div>
<!-- datatable-rows -->
</div>
<!-- datatable -->
</div>
<!-- container -->
这是工作正常的暂存器 http://scratchpad.io/glib-line-6058
答案 0 :(得分:1)
这花了我一段时间,但很显然,这与某些标签的背景色有关。 border-radius工作正常,但由于其父元素具有相同的背景色而没有显示。 Chrome会忽略此问题,但Firefox不会。
我更改了:
我从.datatable-header
和.data-table-rows
中删除了背景。
我添加了
.datatable-header .datatable-cell {
background: #dedede;
}
.datatable-rows .datatable-cell {
background-color: #fff;
}
实时代码段:(我夸大了边框半径,这样它们会更容易显示。)
* {
box-sizing: border-box;
}
body {
background-color: #efefef;
}
.container {
display: inline-block;
padding: 50px 50px;
min-width: 100%;
}
.datatable-table {
display: table;
padding: 5px;
min-width: 100%;
}
.datatable-rows {
display: table-row;
padding: 5px;
height: 43px;
font-family: Roboto, sans-serif;
line-height: 1.5;
font-size: 14px;
}
.datatable-filters {
display: table-row;
padding: 5px;
height: 43px;
white-space: nowrap;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
color: #7a7a7a;
border-radius: 3px 3px 0px 0px;
padding: 15px 0px;
}
.datatable-header {
border-radius: 6px 6px 0 0;
display: table-row;
padding: 5px;
height: 43px;
white-space: nowrap;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
color: #7a7a7a;
border-radius: 3px 3px 0px 0px;
padding: 15px 0px;
cursor: pointer;
}
.datatable-header .datatable-cell {
background: #dedede;
}
.datatable-rows .datatable-cell {
background-color: #fff;
}
.datatable-header .datatable-cell:first-child {
border-radius: 6px 0 0 0;
}
.datatable-header .datatable-cell:last-child {
border-radius: 0 6px 0 0;
}
.datatable-rows .datatable-cell:first-child {
border-radius: 0 0 0 12px;
}
.datatable-rows .datatable-cell:last-child {
border-radius: 0 0 12px 0;
}
.datatable-cell {
display: table-cell;
padding: 0 20px;
width: 150px;
margin: 5px;
vertical-align: middle;
text-align: center;
}
<div class="container">
<div class="datatable-table">
<div class="datatable-filters">
<div class="datatable-cell">
<div style="display: flex; justify-content: space-between;">
<input type="text" value="2019-05-12" style="width: 47%">
<input type="text" value="2019-05-12" style="width: 47%">
</div>
</div>
<div class="datatable-cell">Row 1, Column 2</div>
<div class="datatable-cell">Date added</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
</div>
<!-- datatable-filters -->
<div class="datatable-header">
<div class="datatable-cell">Date added</div>
<div class="datatable-cell">Date changed</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short thing</div>
<div class="datatable-cell">Some short things</div>
</div>
<!-- datatable-header -->
<div class="datatable-rows">
<div class="datatable-cell">2019-01-01</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
<div class="datatable-cell">2019-05-12</div>
</div>
<!-- datatable-rows -->
</div>
<!-- datatable -->
</div>
<!-- container -->