html - How to efficiently remove user-agent stylings applied to my anchor tags
问题描述
I'm using Chrome and am styling a
(anchor) tags.
a {
all: unset;
}
I believe all: unset
sets all properties applied to a
either to be initial or inherit
if a property's naturally inheritable (e.g. color
).
a {all: unset}
does maketext-decoration: underline
turn intotext-decoration: none
. However, it doesn't 'unset'color: -webkit-link
(which makes text purple). My solution:a {color: unset}
.
Why am I forced to do this additional solution? And is there a more effective solution other than repeating a {property: unset}
every-time a property not captured by all: unset
is discovered?
- Here's a second example: If I want to make a
a
box-sizing: border-box
,* {box-sizing: border-box}
won't work.a {box-sizing: border-box}
does. I don't know why this is.
Here's something that might be useful. Here's what Chrome Inspector shows me of a
.
a:-webkit-any-link {
color: -webkit-link;
cursor: pointer;
text-decoration: underline;
}
Although it just adds more confusion to me because I thought my solutions (using the a
selector) wouldn't 'capture' a pseudo-class (a:-webkit-any-link
)
P.S.
The ultimate goal behind this question (if this goal is reasonable) is to stop these user-agent stylings (like color
) from being applied to my a
tags (on Chrome & any other browser).
解决方案
这应该是您所需要的:
* {
box-sizing: border-box;
}
a {
color: inherit;
text-decoration: none;
outline: none;
}
<a href="#">yourLink</a>
推荐阅读
- google-cloud-platform - 如何使用 Terraform 将静态 IP 添加到 GCE VM 实例
- c# - ZipFile (System.IO.Compression)、c# (WPF) 的字符提取问题
- sql - 相同 DML 的相同执行时间
- reactjs - 下一个 js Router.push 重新加载页面
- reactjs - 在 react-chartjs-2 中使用纪元作为 x 轴上的时间序列未显示正确的日期
- php - Telegram 不显示通过 Botman 发送的键盘
- angular - Chart.js,增加图表宽度时增加条形及其标签之间的空间
- mysql - MySQL - 如何使用分页从两个表中获取所有记录?
- c - 了解指针数组
- java - 在多个类中共享公共属性的最佳方式是什么?