【发布时间】:2021-02-13 17:29:17
【问题描述】:
所以我想制作一个时钟,正如您在下面的程序中看到的那样,线条没有出现在圆圈上,也找不到它们。请帮助我,我无法弄清楚原因。这是我第一次制作 SVG 绘图,我从没想过会这么难……
HTML
<div class="container">
<div class="frame">
<svg viewBox="0 0 40 40">
<circle cx="20" cy="20" r="19" class="circle"/>
<g class="numbers">
<line x1="0" y1="0" x2="200" y2="200" class="one"/>
<line x1="0" y1="0" x2="200" y2="200" class="two"/>
<line x1="0" y1="0" x2="200" y2="200" class="three"/>
<line x1="0" y1="0" x2="200" y2="200" class="four"/>
<line x1="0" y1="0" x2="200" y2="200" class="five"/>
<line x1="0" y1="0" x2="200" y2="200" class="six"/>
<line x1="0" y1="0" x2="200" y2="200" class="seven"/>
<line x1="0" y1="0" x2="200" y2="200" class="eight"/>
<line x1="0" y1="0" x2="200" y2="200" class="nine"/>
<line x1="0" y1="0" x2="200" y2="200" class="ten"/>
<line x1="0" y1="0" x2="200" y2="200" class="eleven"/>
<line x1="0" y1="0" x2="200" y2="200" class="twelve" />
</g>
</svg>
</div>
</div>
CSS
body{
background-color: darksalmon;
margin: 0%;
padding: 0%;
}
svg{
height: 400px;
}
line{
left : -280px;
top : -187px;
height: 10px;
}
.circle{
float: left;
position: relative;
height: 400px;
fill:thistle;
stroke: black;
stroke-width: 1;
stroke-linecap: round ;
z-index: 2;
}
【问题讨论】:
-
尝试提供笔画和笔画宽度作为属性或与您的 css。
-
为什么所有的行都一样?
-
Svg 元素没有浮动的概念,也不能使用 left 和 top 定位。