代码之家  ›  专栏  ›  技术社区  ›  tonymx227

将图像拉伸到SVG中

  •  0
  • tonymx227  · 技术社区  · 6 年前

    我想将图像拉伸到SVG中,但它似乎没有按预期工作。

    我用了 preserveAspectRatio

    我的代码:

    <svg class="mapSvg" preserveAspectRatio="none" width="1292px" height="649px" viewBox="0 0 1292 649">
    
    <image xlink:href="https://images.sftcdn.net/images/t_app-cover-l,f_auto/p/befbcde0-9b36-11e6-95b9-00163ed833e7/260663710/the-test-fun-for-friends-screenshot.jpg" height="100%" width="100%" x="0" y="0"></image>
    
    <polyline fill="red" stroke="black" points="461.909521484375,221.9047607421875 471.43330078125,220.9523681640625 475.24287109375,212.38095703125 472.385693359375,167.61904296875 477.147607421875,153.3333251953125 462.8619140625,153.3333251953125 460.95712890625,219.047607421875 461.909521484375,221.9047607421875" data-id="0">
    
    </svg>

    1 回复  |  直到 6 年前
        1
  •  1
  •   Ted    6 年前

    移动 preserveAspectRatio="none" 到图像标签。

    <svg class="mapSvg" width="1292px" height="649px" viewBox="0 0 1292 649">
    
      <image preserveAspectRatio="none" xlink:href="https://images.sftcdn.net/images/t_app-cover-l,f_auto/p/befbcde0-9b36-11e6-95b9-00163ed833e7/260663710/the-test-fun-for-friends-screenshot.jpg" height="100%" width="100%" x="0" y="0"></image>
    
      <polyline fill="red" stroke="black" points="461.909521484375,221.9047607421875 471.43330078125,220.9523681640625 475.24287109375,212.38095703125 472.385693359375,167.61904296875 477.147607421875,153.3333251953125 462.8619140625,153.3333251953125 460.95712890625,219.047607421875 461.909521484375,221.9047607421875" data-id="0">
    
    </svg>