CSS rules for webkit based browsers

前端 未结 1 1565
难免孤独
难免孤独 2021-02-06 01:59

I have the next CSS code:

#mgheader .letters {
  display: inline-block;
  margin-left: 55px;
  margin-top: -45px;
  position: absolute;
}

#mgheader .letters {
          


        
1条回答
  •  故里飘歌
    2021-02-06 02:46

    The problem is that you're overriding your webkit styling with the non-webkit styling. Reversing the order should fix this:

    #mgheader .letters {
      display: inline-block;
      margin-left: 10px;
      position: absolute;
    }
    
    @media screen and (-webkit-min-device-pixel-ratio:0) {
      #mgheader .letters {
        display: inline-block;
        margin-left: 55px;
        margin-top: -45px;
        position: absolute;
      }
    }  
    

    You may also want to check that your -webkit-min-device-pixel-ratio fires on all webkit-using devices, but it probably does.

    For reference, Cascading Style Sheets are read from top to bottom. The key word is Cascading. If one CSS rule is given before an identical CSS rule, the latter one will take precedence. In your example you were styling specifically to webkit browsers but then overriding it with the general styling rules. Reversing the order means that the webkit styling here will override the general styling (without affecting non-webkit browsers).

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