1.什么是浏览器默认样式?
如图所示,F12开发者工具中可以看到当前的样式用到的CSS是什么:user agent stylesheet
2.如何获取到对应的css?
- Mozilla Firefox:
https://dxr.mozilla.org/mozilla-central/source/layout/style/res/html.css
- Google Chrome:
https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css
- Safari (WebKit):
https://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css
- Internet Explorer: You can’t view Internet Explorer’s UA Stylesheet because it’s not open source.
3.如何理解默认样式?
比如:
input元素的focus状态:
/* focusable content: anything w/ tabindex >=0 is focusable */
:-moz-focusring {
/* Don't specify the outline-color, we should always use initial value. */
outline: 1px dotted;
}
iframe:-moz-focusring,
body:-moz-focusring,
html:-moz-focusring {
/* These elements historically don't show outlines when focused by default.
* We could consider changing that if needed. */
outline-style: none;
}
待续。