How To Isolate a div from public CSS styles?

后端 未结 5 1681
栀梦
栀梦 2020-11-27 13:44

i have some code for example here in html


 
  
  

Hi it\'s test

5条回答
  •  无人及你
    2020-11-27 13:57

    One thing that might be helpful is the CSS direct child selector, which is available in all browsers including IE7+. That lets you apply styling that doesn't cascade down into children. For example in your code you could use this CSS:

    body > img {
      width:100px;
      height:100px;
    }
    body > h1 {
      font-size:26px;
      color:red;
    }
    

    And that CSS would only apply to elements directly on the BODY element.

提交回复
热议问题