【问题标题】:SVG pattern image cut off in webkit browsersSVG 图案图像在 webkit 浏览器中被截断
【发布时间】:2016-12-01 05:28:24
【问题描述】:

我创建了具有图案图像的药丸 svg。它在 FF、IE、Edge 中看起来很完美,但在 Chrome、Opera(webkit 浏览器)中图像被截断。这个问题也出现在 Mac 的 Safari 和 firefox 上。 这是codepen中的示例:http://codepen.io/reinis/pen/wWXdbz

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 240 240"> <defs> <pattern id="imgpattern" x="0" y="0" width="1" height="1"> <image width="240" height="240" xlink:href="http://www.vrheadsets3d.com/wp-content/uploads/2016/07/dreams-of-dali-400x400.jpg"/> </pattern> </defs> <path fill="url(#imgpattern)" d="M17.654,17.654C-5.93,41.238-5.878,79.528,17.77,103.176l59.448,59.448l59.606,59.606c23.648,23.648,61.938,23.7,85.522,0.116s23.532-61.874-0.116-85.522l-59.488-59.488L103.176,17.77 C79.528-5.878,41.238-5.93,17.654,17.654z" /> </svg>

谁能弄清楚发生了什么?

【问题讨论】:

    标签: svg


    【解决方案1】:

    只需将视图框更改为“0 0 300 300”并将图像宽度和高度也更改为 300,在 SVG 中您将面临很多与视图框相关的问题,因此为了更好地理解请查看此链接 https://sarasoueidan.com/blog/svg-coordinate-systems/

    【讨论】:

    • 哦,非常简单的解决方案。谢谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 2023-02-13
    • 2018-10-11
    相关资源
    最近更新 更多