html - 媒体查询曾经是 CSS2 的一部分吗?

标签 html css

我有一个简单的问题 - Media_Queries 是出现在 CSS2(1997 年 11 月推出)中还是仅出现在 CSS 3(2011 年 6 月 7 日)中?

Media queries is a feature of CSS3 allowing content rendering to adapt to different conditions such as screen resolution (e.g. mobile and desktop screen size). It became a W3C recommended standard in June 2012,[1] and is a cornerstone technology of responsive web design (RWD).

来源:https://en.wikipedia.org/wiki/Media_queries

CSS2 Introduced Media Types

CSS3 Introduced Media Queries

来源:https://www.w3schools.com/css/css3_mediaqueries.asp

现在,我很困惑。 Media Query 是 CSS2 的一部分吗?它在 CSS3 或其他方面是否已经存在或只是改进?它只是作为 CSS3 或其他什么的新功能出现的吗???

最佳答案

据我所知,CSS2 引入了简单的@media 类型。例如,一种用于屏幕,一种用于打印等。

例如:

@media screen {
    /* screen only */
}
@media print {
    /* print only */
}

CSS3 引入了更复杂的@media 查询。例如,设备的宽度、减少的运动或配色方案。

@media (max-width: 700px) {
    /* viewports under 700px only */
}
@media (prefers-reduced-motion: reduced) {
    /* for motion-reduced browser settings */
}
@media (prefers-color-scheme: dark) {
    /* for dark preferences on browser settings */
}

您可以将它们混合在一起。

@media screen and (min-width: 1000px) {
    /* viewports over 1000px only, on screens */
}
@media print and (orientation: portrait) {
    /* for printing in portrait mode */
}
@media (max-device-width: 700px) and (prefers-color-scheme: light) {
    /* for light preferences on browser settings on devices under 700px wide */
}
@media print and (min-device-width: 900px) and (prefers-reduced-motion: reduced) {
    /* for print, on devices over 900px wide, for reduced motion preferences on the browser settings */
}

TL;DR:CSS2 允许您针对媒体类型执行操作,而 CSS3 允许您针对这些媒体中的不同首选项/设置/尺寸执行操作。

关于html - 媒体查询曾经是 CSS2 的一部分吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63643782/

相关文章:

html - 如何在电子邮件中使用 CSS(特别是设计超链接按钮)

javascript - 添加 d3 svg.selectAll (".foo").style ("fill",...) 覆盖 .foo :hover css rule

html - IE7下边栏下拉的css解决方案

html - CSS高度继承,跳代

javascript - ID不同时更改图像源

html - 在打印时为动态页面添加页眉

php - 如何使用 javascript 和 php 更改 php 读取文件。新Q如何阻止它影响标题

html - 如何在IE6-8中使用HTML5标签和css3?

html - 如何使用 CSS 覆盖 HTML "rules"属性?

html - CSS 拆分边框颜色