What does an underscore “_” mean in CSS?

前端 未结 3 507
梦如初夏
梦如初夏 2021-01-31 15:42

I just found the following snippet in a CSS file:

position: fixed;
_position: absolute;

What does this underline mean in front of the second

相关标签:
3条回答
  • 2021-01-31 16:05

    It's one of a number of CSS "hacks" used to target specific versions of Internet Explorer.

    selector {
        property: value;   /* all browsers */
        property: value\9; /* < IE9 */
        *property: value;  /* < IE8 */
        _property: value;  /* < IE7 */
    }
    

    Generally speaking you should avoid CSS hacks in favor of conditional classes on HTML.

    0 讨论(0)
  • 2021-01-31 16:06

    This is an old CSS-Hack for IE5, 5.5 & 6.
    All browser will display the position:fixed while IE5 - 6 use the _position, so it display it absolute.

    But note: This CSS won't validate! And it won't work for IE5/MAC

    0 讨论(0)
  • 2021-01-31 16:13

    This is a way to give alternative directives to WinIE browsers, since they don't support certain features of the latest CSS definitions. Other browsers will ignore the whole definition (e.g. _position: relative), while WinIE will treat it as position: relative.

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