浏览器默认的 HTML 元素 CSS

在哪里可以找到 HTML 元素的浏览器默认 CSS?

许多 HTML 元素都带有一些默认的 CSS 属性,这些属性有时会导致未知/不想要的行为。例如,在不同的浏览器中,输入框的显示方式不同。我正在寻找一个地方,涵盖新的 CSS3属性和新的 HTML5元素。

我在其他(更老的)问题(例如 浏览器默认的 CSS 样式表)的答案中看到过提出 CSS 重置的解决方案。这个解决方案有时并不需要,通常我会保留一些基本属性(比如 Chrome 中输入框的高亮显示)。换句话说: 我不想因为我不知道它们是干什么的就把它们扔掉

那么,有没有一个网站可以给我所有这些信息(或者大部分) ?

95554 次浏览

每个浏览器都不一样,所以:

  • Firefox (Gecko) : https://dxr.mozilla.org/mozilla-central/source/layout/style/res/html.css。或者,浏览到 resource://gre-resources/并查看 html.css
  • 浏览器/Safari (WebKit) : < a href = “ http://trac.WebKit.org/web 浏览器/躯干/Source/WebCore/css/html.css”rel = “ norefrer”> http://trac.WebKit.org/browser/trunk/source/webcore/css/html.css
    • 返回文章页面谷歌浏览器译者: pestwave 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏览器: 谷歌浏
  • Internet Explorer (三叉戟) ,旧版本: < a href = “ http://web.archive. org/web/2017012223926/http://www.iecss.com/”rel = “ norefrer”> http://web.archive.org/web/20170122223926/http://www.iecss.com/

你也可以看看 HTML5样式表,它“规范化了很多东西的显示,而不是传统意义上的重置”。它还修复了一些 bug/不一致性。

它也值得一看: https://github.com/necolas/normalize.css/blob/master/normalize.css

这里中可以找到所有 W3C HTML 规范和供应商默认 CSS 样式表的 GitHub 存储库

  1. Gecko/Firefox 的默认样式 --
  2. Internet Explorer 的默认样式 --
  3. Webkit/Safari 的默认样式 --
  4. 闪烁/Chrome 的默认样式 --
  5. Opera 的默认样式 --
  6. HTML4的默认样式(W3C 规范) --
  7. HTML5的默认样式(W3C 规范) --

示例,根据默认的 W3C HTML4规范:

html, address,
blockquote,
body, dd, div,
dl, dt, fieldset, form,
frame, frameset,
h1, h2, h3, h4,
h5, h6, noframes,
ol, p, ul, center,
dir, hr, menu, pre   { display: block; unicode-bidi: embed }
li              { display: list-item }
head            { display: none }
table           { display: table }
tr              { display: table-row }
thead           { display: table-header-group }
tbody           { display: table-row-group }
tfoot           { display: table-footer-group }
col             { display: table-column }
colgroup        { display: table-column-group }
td, th          { display: table-cell }
caption         { display: table-caption }
th              { font-weight: bolder; text-align: center }
caption         { text-align: center }
body            { margin: 8px }
h1              { font-size: 2em; margin: .67em 0 }
h2              { font-size: 1.5em; margin: .75em 0 }
h3              { font-size: 1.17em; margin: .83em 0 }
h4, p,
blockquote, ul,
fieldset, form,
ol, dl, dir,
menu            { margin: 1.12em 0 }
h5              { font-size: .83em; margin: 1.5em 0 }
h6              { font-size: .75em; margin: 1.67em 0 }
h1, h2, h3, h4,
h5, h6, b,
strong          { font-weight: bolder }
blockquote      { margin-left: 40px; margin-right: 40px }
i, cite, em,
var, address    { font-style: italic }
pre, tt, code,
kbd, samp       { font-family: monospace }
pre             { white-space: pre }
button, textarea,
input, select   { display: inline-block }
big             { font-size: 1.17em }
small, sub, sup { font-size: .83em }
sub             { vertical-align: sub }
sup             { vertical-align: super }
table           { border-spacing: 2px; }
thead, tbody,
tfoot           { vertical-align: middle }
td, th, tr      { vertical-align: inherit }
s, strike, del  { text-decoration: line-through }
hr              { border: 1px inset }
ol, ul, dir,
menu, dd        { margin-left: 40px }
ol              { list-style-type: decimal }
ol ul, ul ol,
ul ul, ol ol    { margin-top: 0; margin-bottom: 0 }
u, ins          { text-decoration: underline }
br:before       { content: "\A"; white-space: pre-line }
center          { text-align: center }
:link, :visited { text-decoration: underline }
:focus          { outline: thin dotted invert }


/* Begin bidirectionality settings (do not change) */
BDO[DIR="ltr"]  { direction: ltr; unicode-bidi: bidi-override }
BDO[DIR="rtl"]  { direction: rtl; unicode-bidi: bidi-override }


*[DIR="ltr"]    { direction: ltr; unicode-bidi: embed }
*[DIR="rtl"]    { direction: rtl; unicode-bidi: embed }


@media print {
h1            { page-break-before: always }
h1, h2, h3,
h4, h5, h6    { page-break-after: avoid }
ul, ol, dl    { page-break-before: avoid }
}

虽然这是一个老的跨浏览器问题,因为每个浏览器都有自己的渲染和行为与一些 html 元素,如媒体和输入元素,我们现在可以在2017年相当安全地使用 CSS 过滤器属性在他们之上。

这允许使用 色调旋转过滤器提供一个颜色调色板,可以很好地呈现跨浏览器的效果。

下面的代码片段展示了一种使用 输入类型颜色输入类型颜色在 javascript 视频元素上实时呈现这种效果的方法。

为了只使用 css,必须使用这些过滤器中的每一个: 深褐色不为0,高饱和度,灰度为0,高对比度,然后根据我的测试给出具有色相旋转属性的颜色。反相过滤器不是强制性的,但是正在产生一些深层次的效果。

同样,下拉-阴影过滤器在浏览器之间工作得很好。 像这样使用: filter: drop-shadow (2px 20px 50px red) < em > [ X,Y,RADIUS,COLOR ]

function styloElem() {
stylo.dataset.hue = ((parseInt(stylo.value.substring(1), 16))/46666).toFixed(0)
  

media.style.cssText += ";filter:sepia(100%) saturate(1000%)grayscale(0)contrast(200%)hue-rotate("+ stylo.dataset.hue+"deg)invert("+(stylo.dataset.hue/3.6)+"%)"


}
styloElem()
body {
text-align:center;
background:#001;
color: white
}
video {
width:500px;max-width:500px
}
Colors:
<input
type="color"
id="stylo"
oninput="styloElem()"
class="media"
data-hue="0" />


<br><br>


<video
controls
id="media"
onplay="this.removeAttribute('controls');this.style.all='unset'"
onpause="this.controls='controls';styloElem()"
src="https://ia600206.us.archive.org/7/items/MysteresDarchives-Saison04/1944%2c%20Dans%20le%20maquis%20du%20Vercors.ogv"></video>

我可以使用 css 过滤器吗:

Http://caniuse.com/#feat=css-filters

我在 css 过滤器周围做的一个工具栏,从哪里来的这个注释:

Https://github.com/webdev23/ponyfilters

一个更完整的代码加密示例:

Http://codepen.io/nico_krazhtest/pen/bwexeb/

没有人提到 Edge 中 CSS 默认值的任何来源。我查看了一下,没有找到任何权威的东西,但是我发现这个样式表看起来似乎有道理: https://gist.github.com/jonathantneal/abc52743caa0a019d359ec4ba2ce965b