简体   繁体   English

背景图像css不工作在IE11

[英]Background image css not working in IE11

I have a WordPress site in which we are replacing menu links with a background image. 我有一个WordPress网站,我们用一个背景图片替换菜单链接。 Here is an example of the css for one of the menu items. 以下是其中一个菜单项的css示例。

  #menu-item-3039{
    width:30px;
    height:20px;
    border:none;
    padding-right:0;
  }
  #menu-item-3039 a{
    visibility:hidden;
  }
  #menu-item-3039 a::before{
    visibility:visible;
    display:block;
    width:20px;
    height:20px;
    content:"";
    background-size:20px 20px;
  }
  #menu-item-3039 a::before {
    background-image:url("/wp-content/uploads/2015/05/moodle-icon.png");
  }

Is there something very obviously wrong or missing to work with IE11? 使用IE11有什么明显错误或缺失的东西吗?

It works just great in chrome and firefox, but does not work at all in IE11. 它在chrome和firefox中工作得很好,但在IE11中根本不起作用。 I'm not very experienced with IE cross browser support, so it's likely that anything will help. 我对IE浏览器支持不是很有经验,所以任何事情都有可能有所帮助。

Thanks! 谢谢!

IE11 is inheriting the visibility from the a to their ::before . IE11继承了从a到其::beforevisibility

I'd recomend you not to use that rule and use: 我建议你不要使用该规则并使用:

overflow: hidden;
text-indent: -1000px;
height: 20px;
display: block;

instead. 代替。 This way you are hidding the text (what I think that is what you really want to do) and not affecting the background. 这样你就可以隐藏文本(我认为这就是你真正想做的事情)而不影响背景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM