What is the difference between “.class element” and “element.class”?

前端 未结 4 1190
独厮守ぢ
独厮守ぢ 2020-12-23 00:04

Is there a difference between .class element and element.class in a CSS selector?

I had always been shown element.class but j

4条回答
  •  臣服心动
    2020-12-23 00:14

    element.class selects all s with that class. .class element selects all s that are descendants of elements that have that class.

    For example, HTML:

    For example, CSS:

    div.wrapper {
      background-color: white; /* the div with wrapper class will be white */
    }
    
    .wrapper div {
      background-color: red;   /* all 3 child divs of wrapper will be red */
    }
    

提交回复
热议问题