为什么更改按钮的“背景颜色"也会更改其他样式? [英] why does changing the `background-color` of a button change other styles too?

查看:123
本文介绍了为什么更改按钮的“背景颜色"也会更改其他样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://codepen.io/anon/pen/KwKOaz

仅更改background-color会大大改变按钮元素的样式,尤其是border样式.

Changing only the background-color significantly changes the style on a button element, specifically the border style.

在Mac上的Chrome,Safari和Firefox中会发生这种情况.为什么会这样?如何安全更改其背景颜色?

This happens on chrome, safari, and firefox on a Mac. Why does this happen? How can I safely change its background color?

推荐答案

浏览器供应商将自定义样式应用于UI元素,例如按钮和输入字段.更改这些覆盖的属性之一会导致也禁用该元素上的所有其他供应商样式.恐怕如果要更改一个属性,也必须更改其他属性.

Browser vendors apply custom styling to UI elements like buttons and input fields. Altering one of these overwritten attributes results in disabling all of the other vendor styles on that element as well. If you want to change one attribute, you have to alter the others as well, I'm afraid.

不幸的是,我无法告诉您他们为什么这样做-可能后面有一些说明,但是我找不到任何证据.

Unfortunately I can't tell you why they do this - probably there is might be some spec behind, but I cannot find any evidence for that.

这篇关于为什么更改按钮的“背景颜色"也会更改其他样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆