html - - th/td 元素上的 webkit-background 渐变导致导航栏崩溃大幅减慢
问题描述
我一直在尝试为表格中的文本添加线性渐变,到目前为止,它是成功的。在我尝试访问我的安卓设备上的导航栏之前,一切看起来都很棒。在我包含表格的两个页面上,导航栏在折叠时滞后,感觉很糟糕。
在网上研究了这个问题后,我意识到这是一个与过度使用webkit
我的 th/td 元素有关的问题。我完全删除了与 th/td 元素相关的全部独立背景,问题就消失了。我理解它变慢背后的逻辑,但我该如何补救呢?
一张表:
table:not(#tableTeam1, #tableTeam2) tr:nth-of-type(1) td {
font-size: 20px;
font-weight: 100;
background: white;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
table:not(#tableTeam1, #tableTeam2) tr:nth-of-type(1) th {
font-size: 20px;
font-weight: 100;
background: white;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
td,
th:not(.teamsleft) {
font-family: 'Roboto', sans-serif;
font-size: 19px;
font-weight: normal;
background: -webkit-linear-gradient(top right, #ffffff, #656161);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div class="card">
<div class="row">
<div class="col-md-8 col-sm-8 col-xs-9">
<div class="scrolling outer">
<div class="inner">
<table class="table table-hover table-dark table-condensed">
<tr>
<th scope="col" class="firsth" id="topleft">Name</th>
<td scope="col">Positioning</td>
<td scope="col">Handling</td>
<td scope="col">Reflexes</td>
<td scope="col" id="topright">Average</td>
</tr>
<tr>
<th>Jimbo</th>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3.0</td>
</tr>
<tr>
<th>Michael</th>
<td>2.5</td>
<td>3</td>
<td>3</td>
<td>2.83</td>
</tr>
<tr>
<th class="bottomleft">Dwigth</th>
<td>2.5</td>
<td>3</td>
<td>3</td>
<td>2.83</td>
</table>
</div>
</div>
</div>
</div>
</div>
我还有第二张桌子,大约是这张桌子的四倍。
是否有更有效的方法将渐变应用于表格元素?还是我应该考虑完全删除它们?
解决方案
您不再需要不同浏览器的前缀。您可以参考有关它的社区问题。
在其他程度上我看到你的小提琴你已经应用了同样gradient
的。所以你可以通过使用这段代码来解决你的问题
*{
background: -webkit-linear-gradient(top right,#ffffff, #656161);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
并将梯度的任何变化分别应用于elements
if there 。
推荐阅读
- javascript - 如何仅在 JS 中获得四舍五入的小数?
- excel - 如何在保留公式的同时将小数显示为百分比
- r - SD 组内 MLA 使用 statsby
- javascript - 组织数据以从 .json 文件制作表格
- dataframe - 在 weka 上插入 - 不向我显示文件
- c# - 如何在带有 Dapper 的 Windows 窗体应用程序中直接从 PictureBox 保存图像,而无需使用 Dapper 存储过程?
- amazon-s3 - AWS SDK 3 WriteGetObjectResponseCommand 问题
- php - Wordpress 后分页不起作用重定向回发
- react-native - react-native 使用 FCM 推送通知 IOS & Android
- python - 在项目中使用两个连接器时如何正确关闭 MariaDB 和 MySQL 连接