css - SVG 背景图像在::在 IE 中不显示之后

标签 css internet-explorer svg

我有这个 SCSS 代码:

.page-collapse {

  // ...

  &__title {
    // ...
    position: relative;

    &::after {
      background-image: url('data:image/svg+xml;charset=utf8,%3Csvg width="16" height="16" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg"%3E%3Ctitle%3Eicon-plus%3C/title%3E%3Cg id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="square"%3E%3Cg id="modules/cards/events-ext" transform="translate(-183 -1212)" stroke="%232F2F2F" stroke-width="1.5"%3E%3Cg id="ui/plus-black2" transform="translate(184 1213)"%3E%3Cpath d="M7 .5v13m6.5-6.499H.5" id="Line"/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
      background-position: 50%;
      background-size: 100% 100%;
      content: '';
      height: 1rem;
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 1rem;
    }
  }
}

这在 Chrome 和 FF 中运行良好,如下所示:

enter image description here

但在 IE 中不是:

enter image description here

难道 IE 不喜欢::after-Elements 中的背景图像?因为还有另一种情况,使用此代码(覆盖 Bootstraps (4 alpha.6) 自定义复选框类:

.custom-control-input {

  &:checked {
    ~.custom-control-indicator {
      background-color: $white;
      background-image: url("data:image/svg+xml;charset=utf8,%3Csvg width='12' height='11' viewBox='0 0 12 11' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Styleguide' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' stroke-linecap='square'%3E%3Cg id='styles-forms' transform='translate(-333 -2181)' stroke-width='1.5' stroke='%232F2F2F'%3E%3Cg id='Group-2' transform='translate(329 2141)'%3E%3Cg id='Group'%3E%3Cpath id='icon-checkmark' d='M5 46.744L7.2 49l7.8-8'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    }
  }
}

这在所有浏览器中都有效。我看到的唯一区别是第一种情况是在::after 伪元素中。此外,在 IE 开发工具中,相应的 CSS 部分被划掉了:

enter image description here

有什么想法吗?

编辑:我只需要支持低至 IE10

最佳答案

我发现了问题...出于某种原因,IE 中似乎存在某种解析问题,将 ' 与 "互换解决了问题,因此更改此设置:

background-image: url('data:image/svg+xml;charset=utf8,%3Csvg width="16" height="16" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg"%3E%3Ctitle%3Eicon-plus%3C/title%3E%3Cg id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="square"%3E%3Cg id="modules/cards/events-ext" transform="translate(-183 -1212)" stroke="%232F2F2F" stroke-width="1.5"%3E%3Cg id="ui/plus-black2" transform="translate(184 1213)"%3E%3Cpath d="M7 .5v13m6.5-6.499H.5" id="Line"/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E');

background-image: url("data:image/svg+xml;charset=utf8,%3Csvg width='16' height='16' viewBox='0 0 16 16' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3Eicon-plus%3C/title%3E%3Cg id='Symbols' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' stroke-linecap='square'%3E%3Cg id='modules/cards/events-ext' transform='translate(-183 -1212)' stroke='%232F2F2F' stroke-width='1.5'%3E%3Cg id='ui/plus-black2' transform='translate(184 1213)'%3E%3Cpath d='M7 .5v13m6.5-6.499H.5' id='Line'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E");

做的工作...你知道的越多。

关于css - SVG 背景图像在::在 IE 中不显示之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46667122/

相关文章:

javascript - 在浏览器中查看 JSON 文件

javascript - 不要在 IE 中运行 javascript 函数

带有 ffmpeg 的 svg 幻灯片

Javascript - 将带有 SVG 的 HTML div 转换为图像

javascript - 如何使用搜索框滚动到列表中的特定数据

html - 需要有关下拉 CSS 菜单的帮助(困惑的缩进)

html - 如何在 Firefox 中获取外部链接的 SVG 剪辑路径

javascript - 如何在 javascript 中更改 CSS 属性 "display"

javascript - 对象不支持 ie 8 中的属性或方法 'addEventListner'

javascript - GSAP:在制作 SVG 动画时保留以前的转换