gpt4 book ai didi

html - 如何为表格单元格添加边框半径,但不适用于所有浏览器

转载 作者:行者123 更新时间:2023-11-28 14:06:50 24 4
gpt4 key购买 nike

我使用带有表 css 属性的 div 创建了一个简单的数据表。但是当我尝试为我的表格添加圆 Angular 边框时,它在 Firefox 中不起作用。它仅适用于 Chrome。有没有另一种方法可以像这样添加圆形边框半径?

enter image description here

这是我的 table

* {
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 -->

这是一个有效的暂存器 fiddle http://scratchpad.io/glib-line-6058

最佳答案

这花了我一段时间才弄清楚,但显然,它与某些标签的背景颜色有关。 border-radius 工作得很好,但它没有显示出来,因为它的父元素具有相同的背景颜色。 Chrome 会忽略此问题,但 Firefox 不会。

我改变了什么:

  1. 我删除了 .datatable-header.data-table-rows 的背景。

  2. 我加了

.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 -->

关于html - 如何为表格单元格添加边框半径,但不适用于所有浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57117248/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com