Putting -moz-available and -webkit-fill-available in one width (css property)

前端 未结 1 1256
刺人心
刺人心 2020-12-12 20:23

I want to make the width of the footer browser-independent.

For Mozilla I want to use the value of -moz-available, and when a user uses Opera, then CSS

相关标签:
1条回答
  • 2020-12-12 21:07

    CSS will skip over style declarations it doesn't understand. Mozilla-based browsers will not understand -webkit-prefixed declarations, and WebKit-based browsers will not understand -moz-prefixed declarations.

    Because of this, we can simply declare width twice:

    elem {
        width: 100%;
        width: -moz-available;          /* WebKit-based browsers will ignore this. */
        width: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
        width: fill-available;
    }
    

    The width: 100% declared at the start will be used by browsers which ignore both the -moz and -webkit-prefixed declarations or do not support -moz-available or -webkit-fill-available.

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