V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
simple2025
0D
V2EX  ›  HTML

关于 svg 里面 circle 大小问题

  •  
  •   simple2025 · Sep 11, 2017 · 4298 views
    This topic created in 3154 days ago, the information mentioned may be changed or developed.

    有下而这段 html

    <svg width="30" height="30" viewBox="0 0 100 100"  version="1.1" xmlns="http://www.w3.org/2000/svg">
              <circle r="45" cx="50" cy="50" stroke-width="8px"   fill="transparent"></circle>
              <circle r="45" cx="50" cy="50" stroke-width="8px"   fill="transparent" class="progress-bar"></circle>
            </svg>
    

    结果通过审查,知道circle的大小是27*27
    所以我有个问题

    1. 有没有办法在保证 svg 的大小是30*30的情况下,使 circle 的大小变成27*27
    2. 如果必须改变svg的大小30/(27/30)=33.3,这种做法你们都是这么做的吗?
    1 replies    2017-09-15 15:09:09 +08:00
    ThomasChan
        1
    ThomasChan  
       Sep 15, 2017
    没看懂你的问题
    svg width 30 height 30
    viewBox 是 0 0 100 100
    则 circle 的 27 = (30 * (45 / 100)) * 2

    viewBox 对原画布尺寸 30 * 30 进行放大到了 100 * 100

    所以放大后的 circle 是 90 * 90 的, 缩小回 30 * 30 的画布上就是 27 * 27 的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   845 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:42 · PVG 03:42 · LAX 12:42 · JFK 15:42
    ♥ Do have faith in what you're doing.