Why are my CSS properties being overridden/ignored?

后端 未结 5 778
名媛妹妹
名媛妹妹 2020-12-03 21:27

I\'m having some issues with the CSS \"hierarchy\" (not sure if it\'s proper to call it a hierarchy). I\'m trying to style the below bit of HTML.



        
5条回答
  •  猫巷女王i
    2020-12-03 21:38

    Elements id have the priority in CSS since they are the most specific. You just have to use the id:

    #content li.post-item > * {
      margin: 0px;
    }
    
    #content .item-description {
      color: #FFF;
    }
    
    #content .item-meta {
      color: #666;
    }
    

    Basically id have the priority on class which the priority on tags(p,li,ul, h1...). To override the rule, just make sure you have the priority ;)

提交回复
热议问题