CSS Equivalent of the “if” statement

前端 未结 12 1374
暖寄归人
暖寄归人 2020-12-01 13:49

Is there any way to use conditional statements in CSS?

12条回答
  •  自闭症患者
    2020-12-01 14:29

    No you can't do if in CSS, but you can choose which style sheet you will use

    Here is an example :

    
    

    will use only for IE 6 here is the website where it is from http://www.quirksmode.org/css/condcom.html , only IE has conditional comments. Other browser do not, although there are some properties you can use for Firefox starting with -moz or for safari starting with -webkit. You can use javascript to detect which browser you're using and use javascript if for whatever actions you want to perform but that is a bad idea, since it can be disabled.

提交回复
热议问题