【问题标题】:SVG clock hour hand lengthSVG时钟时针长度
【发布时间】:2015-05-29 23:36:13
【问题描述】:

我一直在代码笔http://codepen.io/knitevision1/pen/qfdne上玩这个时钟。

谁能帮我缩短时针的长度?我试过改变高度,但它似乎是从外向内拉手。

有问题的代码是:

<div id="clock-container"  style="padding-left:180px;">
<font color="white" size="1">&nbsp;&nbsp;&nbsp;London</font>
<svg id="clock" viewBox="0 0 100 100">
  <circle id="face" cx="50" cy="50" r="45"/>
  <g id="hands">
    <rect id="hour" x="47.5" y="12.5" width="5" height="40" rx="2.5" ry="2.55" />
    <rect id="min" x="48.5" y="12.5" width="3" height="40" rx="2" ry="2"/>
    <line id="sec" x1="50" y1="50" x2="50" y2="16" />
  </g>
</svg>
</div>

谢谢!

【问题讨论】:

    标签: css svg clock


    【解决方案1】:

    只需更改height 和y。例如,对于 20px 更短:

    <rect id="hour" x="47.5" y="32.5" width="5" height="20" rx="2.5" ry="2.55" />
    

    时钟的中心位于50, 50,因此x 和y 的双手公式为:

    x = 50 - width/2
    y = 50 - height
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      相关资源
      最近更新 更多