CSS的执行顺序

扫码查看
本文介绍了CSS的执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇知道CSS文件中语句的执行顺序。我在CSS文件中有以下CSS:

I am so curious to know the sequence of execution of statements in the CSS file. I have the following CSS in the CSS file :

/* screen width larger than 800px */
@media screen (min-width: 800px) {
     .indexphototd {
            width:200px !important;
        }
     .indexphoto {
         width:200px !important;
      }
}

/* screen width larger than 1200px */
@media screen (min-width: 1200px) {
     .indexphototd {
            width:300px !important;
        }
     .indexphoto {
         width:300px !important;
      }
}


/* default setting */
.indexphototd {
    width:500px !important;
   }
.indexphoto {
    width:500px !important;
   }

在上面的代码中,我已经声明2类的设置2不同的屏幕尺寸,后面我提到了2个语句,没有对屏幕尺寸的限制(即默认)。

In the code above I have declared 2 types of settings of 2 classes in 2 different screen sizes, and AFTER that I have mentioned 2 statements without the restriction on the screen sizes (that is, default).

我的目标是,屏幕尺寸不落入上述两组,它必须采取在下面第三个设置的默认值。

My objective is, the screen size does not fall into those 2 groups above, it has to take the default value set in the 3rd one below.

但我想知道默认设置是否会覆盖屏幕尺寸特定的设置,因为我在最后插入默认设置。我必须把它放在开始吗?请让我知道在CSS中的执行顺序。我知道CSS不是一种编程语言。我是新的web开发和学习所有这些微小的东西。请帮帮我。非常感谢。

But I am wondering if the default settings would override the screen-size specific settings since I have inserted the default setting at the very end. Do I have to put it at the beginning? Could you please let me know the sequence of execution in the CSS. I know CSS is not a programming language. I am new to web development and learning all these minute stuff. Please help me. Thanks.

Isaac

推荐答案

/* General CSS here */

/* CSS for min-width 800 here, overides general */

/* CSS for min-width 1024 here, overides both general and 800 */

这篇关于CSS的执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 13:05
查看更多