html - 使这个 SVG 全宽

标签 html css svg

我看过有关 SVG 的一般操作方法。我认为这是关于这个的一些特定的东西。这是代码。

<div><svg width=100% height=100% version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="299px" height="289px" viewBox="0 0 299 289" enable-background="new 0 0 299 289" xml:space="preserve">
  <path fill="url(#skyGradient)" d="M293.468,275.282c0,1.617-1.311,2.928-2.928,2.928H8.46c-1.617,0-2.928-1.311-2.928-2.928V13.718
  c0-1.617,1.311-2.928,2.928-2.928h282.08c1.617,0,2.928,1.311,2.928,2.928V275.282z"/>
  <g>
    <polygon fill="#7A5034" stroke="#7A5034" stroke-width="1.9519" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
    67.032,174.069 96.807,225.639 126.581,277.21 67.032,277.21 12.484,277.21 39.258,225.639   "/>
    <polygon fill="#7A5034" stroke="#7A5034" stroke-width="1.9519" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
    130.469,185.854 160.243,231.532 190.017,277.21 130.469,277.21 70.921,277.21 100.695,231.532   "/>
    <polygon fill="#7A5034" stroke="#7A5034" stroke-width="1.9519" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
    195.858,154.624 225.632,215.917 255.406,277.21 195.858,277.21 136.309,277.21 166.083,215.917  "/>
    <polygon fill="#7A5034" stroke="#7A5034" stroke-width="1.9519" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
    233.92,185.854 259.694,230.532 287.468,277.21 233.92,277.21 174.371,277.21 204.145,231.532  "/>
  </g>

  <defs>
    <linearGradient id="skyGradient" x1="100%" y1="100%">
      <stop offset="0%" stop-color="lightblue" stop-opacity=".5">
        <animate attributeName="stop-color" values="lightblue;blue;red;red;black;red;red;purple;lightblue" dur="14s" repeatCount="indefinite" />
      </stop>
      <stop offset="100%" stop-color="lightblue" stop-opacity=".5">
        <animate attributeName="stop-color" values="lightblue;orange;purple;purple;black;purple;purple;blue;lightblue" dur="14s" repeatCount="indefinite" />
        <animate attributeName="offset" values=".95;.80;.60;.40;.20;0;.20;.40;.60;.80;.95" dur="14s" repeatCount="indefinite" />    
      </stop>
    </linearGradient>
  </defs>

密码本:

https://codepen.io/anon/pen/JvaNeW

据我所知,它一定与“d=”行有关,但我似乎无法理解或修复它。

最佳答案

我想通了,就是

<path fill="url(#skyGradient)" d="M0,0L0,298L299,298L299,0L0,0z"></path> 

这使得它成为全宽和全高

关于html - 使这个 SVG 全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50355786/

相关文章:

html - 不要在整行中显示背景图片

应用于 <col> 元素的 CSS 类未完全应用

css - 透明镂空或镂空圆形

html - 是否可以在 IMG 标签中使用 SVG?

javascript - 在 svg 图片的不同部分添加事件监听器

javascript - 如何从触发器 x 触发 y 元素的 css 动画

javascript - jQuery Accordion 显示特定选项卡

javascript - iframe resize跨域无控制

html - 固定宽度且无换行的 float 右标题

html - 导航栏中的垂直居中菜单