在哪里可以找到浏览器的 HTML 元素的默认 CSS?
许多 HTML 元素都带有一些默认 CSS 属性,这些属性有时会导致未知/不需要的行为。例如,输入框在不同的浏览器中显示不同。我正在寻找一个涵盖新 CSS3 属性和新 HTML5 元素的地方。
我在其他(更老的)问题(例如 浏览器的默认 CSS 样式表)中看到了这样的答案建议CSS重置的解决方案。有时不需要这个解决方案,通常我实际上想保留一些基本属性(例如Chrome中输入框的突出显示)。换句话说:我不想仅仅因为我不知道它们是做什么就扔掉它们。
那么,是否有一个网站可以为我提供所有这些信息(或者可能是大部分信息)?
Where can I find a browser's default CSS for HTML elements?
Many HTML elements come with some default CSS properties which can sometimes result in unknown/unwanted behaviour. For example Input boxes are displayed differently in different browsers. I'm looking for a place that covers the new CSS3 properties and the new HTML5 elements.
I've seen in other (much older) questions (such as Browsers' default CSS stylesheets) answers that suggest a solution of CSS reset. This solution is sometimes not wanted, often I would actually like to keep some of the basic properties (such as the highlighting of input boxes in Chrome). In other words: I don't want to get rid of things just because I don't know what they do.
So, Is there a site that can give me all this information (or perhaps most)?
发布评论
评论(4)
每个浏览器都不同,因此:
resource://gre-resources/
并查看html.css
。您还可以查看HTML5 Boilerplate 样式表,它“标准化了很多东西,而不是传统意义上的重置”。它还修复了相当多的错误/不一致之处。
它还值得一看: https://github.com/necolas/normalize .css/blob/master/normalize.css
It's different for each browser, so:
resource://gre-resources/
and look athtml.css
.You can also look at the HTML5 Boilerplate stylesheet, which "normalizes the display of a lot of stuff without being a reset in the traditional sense". It also fixes quite a few bugs/inconsistencies.
It's also worth looking at: https://github.com/necolas/normalize.css/blob/master/normalize.css
所有 W3C HTML 规范和供应商默认 CSS 样式表的 GitHub 存储库可以在恢复浏览器/规范默认值中找到CSS 样式
--
--
--
--
--
--
--
示例,根据默认的 W3C HTML4 规范:
A GitHub repository of all W3C HTML spec and vendor default CSS stylesheets can be found in Restore Browser/Spec default CSS styles
--
--
--
--
--
--
--
Sample, per the default W3C HTML4 spec:
没有人提到 Edge 中 CSS 默认值的任何来源。我看了看,找不到任何权威的东西,但我发现这个样式表看起来似乎合理: https://gist.github.com/jonathantneal/abc52743caa0a019d359ec4ba2ce965b
No one has mentioned any source for the CSS defaults in Edge. I looked, and I couldn't find anything authoritative, but I found this stylesheet that looks plausible: https://gist.github.com/jonathantneal/abc52743caa0a019d359ec4ba2ce965b
虽然这是一个古老的跨浏览器问题,因为每个浏览器都有自己的渲染和某些 HTML 元素(如媒体和输入元素)的行为,我们现在可以在 2017 年相当安全地使用 CSS filters 属性他们。
这允许提供带有 hue-rotate 过滤器的调色板,可以很好地跨浏览器渲染。
以下代码片段展示了一种使用输入类型颜色通过 JavaScript 在视频元素上实时渲染此效果的方法。
要仅使用 CSS,必须使用每个过滤器:棕褐色不为 0、高饱和度、灰度为 0、高对比度,然后根据我的测试,使用色调旋转属性给出一种颜色。反转过滤器不是强制性的,但会产生一些深层效果。
此外,阴影过滤器在跨浏览器上运行得非常好。
像这样使用:filter:drop-shadow(2px 20px 50px red)[X,Y,RADIUS,COLOR]
我可以使用 CSS 过滤器吗:
http://caniuse.com/#feat=css-filters
我围绕 CSS 过滤器制作的工具栏,以下注释来自于:
https://github.com/webdev23/ponyFilters
更完整的 codepen 示例:
http://codepen.io/Nico_KraZhtest/pen/bWExEB/
While this is an old cross browser problem, as each browsers has his own rendering and behavior with some HTML elements like medias and inputs elements, we can now in 2017 use pretty safely the CSS filters property on top of them.
This allow to give a color palette with the hue-rotate filter that will render pretty well cross browsers.
The following snippets show a way to use a input type color to render this effect in realtime on a video element with javascript.
To use only CSS, this is mandatory to use each one of this filters: sepia not at 0, high saturation, grayscale at 0, high contrast, and then give a color with the hue-rotate property, following my tests. The invert filter isn't mandatory, but is giving some deep effects.
As well, the drop-shadow filter is working pretty nicely cross browser.
To be use like this: filter:drop-shadow(2px 20px 50px red) [X,Y,RADIUS,COLOR]
Can i use CSS filters:
http://caniuse.com/#feat=css-filters
A toolbar I made around CSS filters, from where are coming this notes:
https://github.com/webdev23/ponyFilters
A more complete codepen example:
http://codepen.io/Nico_KraZhtest/pen/bWExEB/