why does changing the `background-color` of a button change other styles too?

前端 未结 3 1472
别那么骄傲
别那么骄傲 2020-12-11 16:08

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

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

3条回答
  •  悲哀的现实
    2020-12-11 16:46

    When all the styles are untouched, the browser uses the host OS's given API to render the given control. This will make the control look native to the platform, but if you apply any style to that control/element, the browser cannot guarantee that the given style can be applied in the given platform, so it defaults back to a simplified, fully css solution.

    Also note, that styling control elements, though works, not covered by stable standards yet.

    For example, the NSButton (native control behind the button in OS X) doesn't have an option to set the background color, so the browser faces an impossible task. On Windows, you can change the background color, this is why people report not seeing your issue on Windows.

提交回复
热议问题