2016-01-13 59 views
1

HTML代码: 如何在两个条件类中选择多个类?

<html class="mobile portrait"> 
    <body> 
     <div> 
      <header> 
       <img class="company_logo"> 
      </header> 
      <section> 
       <div> 
        <img class="company_logo"> 
       </div> 
      </section> 
      <footer> 
       <img class="company_logo"> 
      </footer> 
     </div> 
    </body> 
</html> 

为了display: none;,如何申请一个规则.company_logo.mobile .portrait


更新编辑HTML代码中加入多个company_logo。从代码的问题删除:

/* CSS code */ 
.mobile .portrait > body > div > header > .company_logo { 
    display: none; 
} 
+0

'.mobile.portrait .company_logo'?这就是说找到一个'company_logo'类的元素,这个类里面的两个类都是'mobile,portrait' –

+1

顺便说一下,它应该是'.mobile.portrait> ....'(不含空格) –

+1

什么@JuanMendes说,由于它们在同一个标​​签上,所以'.mobile'和'.portrait'之间没有空格。 '.mobile.portrait .company_logo' –

回答

4
/* Matches elements with the class of company_logo that are 
    inside an element with both "mobile" and "portrait" classes */ 
.mobile.portrait .company_logo { 
    /* style here */ 
} 
+0

我更新了问题。 – quantme