SVG时钟时针长度

  • 本文关键字:时钟 SVG css svg clock
  • 更新时间 :
  • 英文 :


我一直在玩这个时钟代码笔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>

谢谢!

简单地改变heighty。例如,对于20px较短:

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

时钟的中心在50, 50,因此两个指针的xy的公式为:

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

最新更新