html - 默认@media 查询样式

标签 html css responsive-design

媒体查询的特殊性是什么?为什么删除封装最小屏幕宽度的媒体查询会覆盖小屏幕的媒体查询?

<style>
@media only screen and (max-width: 600px) {

  table,tr,td {
    width:100%; 
    margin:0 0 ;
/* background-color: #CCFF33 !important; */
  }

img {
        max-width: 100%;
        height: auto;
  }
}
@media only screen and (min-width: 600px) { 
  table,tr,td {  /* removing this encapsulation yields fix width for */
              margin:0 auto; /* all screens */
              width: 600px;
  }
}
</style>

最佳答案

What is the specificity on media queries?

媒体查询对特异性没有任何影响。

Why does removing the media query encapsulating minimum screen widths override the media query for small screens?

因为特异性是相同的——你的两个规则都使用简单的元素选择器——它归结为规则的顺序,后者获胜。

关于html - 默认@media 查询样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36482956/

相关文章:

html - 如何让 html 内容在初始 View 之外重复/加载?

HTML/CSS Facebook 链接

html - 如何在嵌套行 Bootstrap 上设置断点

html - 在 bootstrap 中,我无法使用自定义 css 更改列表元素的颜色?

html - border-bottom CSS 规则不会在鼠标关闭时过渡,但会在悬停时过渡

javascript - HTML 两种语言 input-label,可以吗?

html - 如何设置每个 tr 组第一行的样式?

jquery - 使用手机时如何使导航栏折叠

html - 如何在响应式设计中显示全尺寸窗口后的菜单

html - 网站在 Safari 中有效,但在 Firefox 中无效