css - SVG 在 Mac Safari 中不可见

标签 css svg safari

我创建了一个 svg 并在 <svg><use xlink="#id"></use></svg> 中使用它.

在除 Mac Safari 之外的所有浏览器中都可以。

here's a link .

<svg class="progress" x="0px" y="0px" viewBox="0 0 55.917 59.667">
    <use xlink:href="#progressSVG"></use>   
</svg>

<svg version="1.1" class="hide" x="0px" y="0px" width="55.917px" height="59.667px" viewBox="0 0 55.917 59.667" enable-background="new 0 0 55.917 59.667" xml:space="preserve">
<g id="progressSVG">
    <polygon points="1.083,35.417 20.083,16.583 27.249,23.336 46.313,4.999 43.208,2.042 55.917,0 53.802,12.167 50.521,9.385 27.458,32.792 20.25,25.667 6.208,40.292 "/>
    <rect x="0" y="44.667" width="14.917" height="15"/>
    <rect x="20.62" y="37.667" width="14.917" height="22"/>
    <rect x="40.537" y="27.667" width="14.917" height="32"/>
</g>
</svg>


.hide{
display:none;
}
.progress{
width:150px;
height:150px;
}

最佳答案

似乎 safari 有一个错误 <use>仅当指向的东西位于同一 SVG 片段中时才有效,例如

.progress{
width:150px;
height:150px;
}
<svg class="progress" x="0px" y="0px" viewBox="0 0 55.917 59.667">
  <defs>
  <g id="progressSVG">
    <polygon points="1.083,35.417 20.083,16.583 27.249,23.336 46.313,4.999 43.208,2.042 55.917,0 53.802,12.167 50.521,9.385 27.458,32.792 20.25,25.667 6.208,40.292 "/>
    <rect x="0" y="44.667" width="14.917" height="15"/>
    <rect x="20.62" y="37.667" width="14.917" height="22"/>
    <rect x="40.537" y="27.667" width="14.917" height="32"/>
</g>
    </defs>
<use xlink:href="#progressSVG"></use>   
</svg>                                                                       

关于css - SVG 在 Mac Safari 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29790698/

相关文章:

html - 在 Ag Grid 中动态更改或设置单元格类别

javascript - JQuery 鼠标悬停事件的兼容性问题

javascript - 如何将列插入网页

javascript - 仅使用 getBoundingClientRect 查找 svg 特定区域中的元素

html - Flexbox 不遵守 overflow-x : hidden on body (Safari/iOS webkit)

html - CSS:选择具有特定类的 li 元素

javascript - 缩放后如何应用 d3.js svg 裁剪

javascript - 如何使用 Javascript 获取完整的 Canvas 内容(甚至隐藏的内容)?

objective-c - 是否可以从iOS应用程序在Google Chrome和Opera中打开链接(如iOS中的 Safari )

javascript - 为什么在 Safari 中相同宽度的 Select 和 Input 标签在渲染时会大不相同