How do I remove background-image in css?

前端 未结 10 1782
孤街浪徒
孤街浪徒 2020-12-01 01:39

I have a general rule which gives all DIVs a background image.
I have one div (with id=\'a\') which I don\'t want it to have the background image.
What css rule do I

相关标签:
10条回答
  • 2020-12-01 02:31
    div#a {
        background-image: none;
    }
    
    0 讨论(0)
  • 2020-12-01 02:31

    When background-image: none !important; have no effect. You can use:

    background-size: 0 !important;
    
    0 讨论(0)
  • 2020-12-01 02:32

    If your div rule is just div {...}, then #a {...} will be sufficient. If it is more complicated, you need a "more specific" selector, as defined by the CSS specification on specificity. (#a being more specific than div is just single aspect in the algorithm.)

    0 讨论(0)
  • 2020-12-01 02:33
    div#a {
      background-image: url('../images/spacer.png');
      background-image: none !important;
    }
    

    I use a transparent spacer image in addition to the rule to remove the background image because IE6 seems to ignore the background-image: none even though it is marked !important.

    0 讨论(0)
提交回复
热议问题