forward slash in CSS? Is this some browser specific thing?

一世执手 提交于 2019-12-22 05:59:56

问题


I inherited a CSS stylesheet and in a few places it does things like:

margin:7px 0 0 0;
/margin-top:9px;

or

background: url(../images/list-hover.png) 0 0 no-repeat;
/background:url(../images/lists-hover.png) 0 2px no-repeat;

anyone know what that forward slash is doing?


回答1:


It's to target LTE IE7. This hack isn't known as much as the IE6 underscore one.

    #myelement {
background:red; /*Should show as red in all browsers, expect IE6 and IE7 because...*/
/background:yellow; /*IE7 should have yellow*/
_background:green; /*IE6 should have green*/
}

You can make the backslash almost anything you want really, expect the underscore _ as that will target IE6. I use the $ personally.

EDIT:
I've included the IE6 trick too there, as anything IE7 and below will take the / property unless you also have an _ property too.

To target IE8, IE7, and IE6 you need to have that order above.



来源:https://stackoverflow.com/questions/5794804/forward-slash-in-css-is-this-some-browser-specific-thing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!