css - css伪元素的SVG回退?

标签 css svg

我正在创建一个站点并在 .svg 中添加一些装饰,但我知道某些浏览器无法显示它们,而应该指定一个 .png回退。

装饰是用:after伪元素添加的。这足以启用 .png 回退吗?

.section header h3:after {
    content: url("../images/ornament.svg");
    content: url("../images/ornament.png");
    width: 66px;
    height: 33px;
    position: absolute;
    bottom: -10px;
    left: 50%;
    margin-left: -33px;
}

最佳答案

.png 文件必须放在第一位。

.section header h3:after {
    content: url("../images/ornament.png");
    content: url("../images/ornament.svg");
    width: 66px;
    height: 33px;
    position: absolute;
    bottom: -10px;
    left: 50%;
    margin-left: -33px;
}

编辑:

但这不会解决您的回退问题,您应该考虑其他选择。这些包括但不限于:

  • 填充
  • 条件语句
  • 服务器端图像转换

关于css - css伪元素的SVG回退?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30149883/

相关文章:

html - css 中的文本渲染,它是什么?以及如何使用它?

jquery - 点击切换打开所有的div,如何避免呢?

javascript - 将外部 SVG 加载到 SVG 中

javascript - 具有相同 ID 的多个 svg

javascript - 未调用 React 事件监听器函数

asp.net - 添加 mime 类型后 SVG 仍未出现

jquery - Bootstrap 3 : create 2 blocks with their own content in the same line with bootstrap 3 container

html - Div 1 行文本 = 底部,Div 超过 1 行 = 顶部

jquery - 我可以在 jquery 中附加到 css 背景 url 吗?

html - 如何将样式应用于嵌入式 SVG?