변환의 시계 구현
다음은 구현된 코드입니다.
<style type="text/css">
*</span>{<span style="color: #ff0000;">
margin</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">
padding</span>:<span style="color: #0000ff;"> 0</span>;
}<span style="color: #800000;">
#wrap</span>{<span style="color: #ff0000;">
width</span>:<span style="color: #0000ff;"> 200px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 200px</span>;<span style="color: #ff0000;">
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
left</span>:<span style="color: #0000ff;"> 50%</span>;<span style="color: #ff0000;">
top</span>:<span style="color: #0000ff;"> 50%</span>;<span style="color: #ff0000;">
margin-left</span>:<span style="color: #0000ff;"> -100px</span>;<span style="color: #ff0000;">
margin-top</span>:<span style="color: #0000ff;"> -100px</span>;<span style="color: #ff0000;">
border</span>:<span style="color: #0000ff;"> 1px solid black</span>;<span style="color: #ff0000;">
border-radius</span>:<span style="color: #0000ff;"> 50%</span>;
}<span style="color: #800000;">
#list > li</span>{<span style="color: #ff0000;">
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
list-style</span>:<span style="color: #0000ff;"> none</span>;<span style="color: #ff0000;">
background</span>:<span style="color: #0000ff;"> black</span>;<span style="color: #ff0000;">
left</span>:<span style="color: #0000ff;"> 99px</span>;<span style="color: #ff0000;">
top</span>:<span style="color: #0000ff;"> 0px</span>;<span style="color: #ff0000;">
width</span>:<span style="color: #0000ff;"> 2px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 8px</span>;<span style="color: #ff0000;">
transform-origin</span>:<span style="color: #0000ff;"> center 100px</span>;
}<span style="color: #800000;">
#list > li:nth-child(5n+1)</span>{<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 12px</span>;
}<span style="color: #800000;">
.licon</span>{<span style="color: #ff0000;">
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
width</span>:<span style="color: #0000ff;"> 20px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 20px</span>;<span style="color: #ff0000;">
background</span>:<span style="color: #0000ff;"> pink</span>;<span style="color: #ff0000;">
border-radius</span>:<span style="color: #0000ff;"> 50%</span>;<span style="color: #ff0000;">
left</span>:<span style="color: #0000ff;"> 90px</span>;<span style="color: #ff0000;">
top</span>:<span style="color: #0000ff;"> 90px</span>;
}<span style="color: #800000;">
.hour</span>{<span style="color: #ff0000;">
width</span>:<span style="color: #0000ff;"> 6px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 30px</span>;<span style="color: #ff0000;">
background</span>:<span style="color: #0000ff;"> black</span>;<span style="color: #ff0000;">
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
left</span>:<span style="color: #0000ff;">96px </span>;<span style="color: #ff0000;">
top</span>:<span style="color: #0000ff;"> 70px</span>;<span style="color: #ff0000;">
transform-origin</span>:<span style="color: #0000ff;"> center bottom</span>;
}<span style="color: #800000;">
.min</span>{<span style="color: #ff0000;">
width</span>:<span style="color: #0000ff;"> 4px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 50px</span>;<span style="color: #ff0000;">
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
background</span>:<span style="color: #0000ff;"> black</span>;<span style="color: #ff0000;">
left</span>:<span style="color: #0000ff;"> 98px</span>;<span style="color: #ff0000;">
top</span>:<span style="color: #0000ff;"> 50px</span>;<span style="color: #ff0000;">
transform-origin</span>:<span style="color: #0000ff;"> center bottom</span>;
}<span style="color: #800000;">
.sec</span>{<span style="color: #ff0000;">
width</span>:<span style="color: #0000ff;"> 2px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 70px</span>;<span style="color: #ff0000;">
position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
left</span>:<span style="color: #0000ff;"> 99px</span>;<span style="color: #ff0000;">
top</span>:<span style="color: #0000ff;"> 30px</span>;<span style="color: #ff0000;">
background</span>:<span style="color: #0000ff;"> red</span>;<span style="color: #ff0000;">
transform-origin</span>:<span style="color: #0000ff;"> center bottom</span>;
}<span style="color: #800000;">
</style>
<div id="wrap">
<ul id="list">
</ul>
<div class="hour"/>
<div class="min"/>
<div class="sec"/>
<div class="licon"/>
</div>
<script type="text/javascript" src="js/jquery-1.10.1.js"/>
<script type="text/javascript">
$(function()</span>{<span style="color: #ff0000;">
var $listNode = $("#list");
var $headNode = $("head>style");
var hours = $(".hour");
var mins = $(".min");
var secs = $(".sec");
var licons = $(".licon");
for (var i =0 ; i < 60; i++){
$listNode.append("<li></li>")
$headNode.append("#list > li</span>:<span style="color: #0000ff;">nth-of-type("+(i+1)+"){transform: rotate("+(i*6)+"deg)</span>;}<span style="color: #800000;">")
}
// , , 。
move()
setInterval(move,1000)
function move()</span>{<span style="color: #ff0000;">
console.log('aaa')
var date = new Date()
var sec = date.getSeconds()
var min = date.getMinutes()+sec/60
var hour = date.getHours()+min/60
secs.css("transform","rotate("+(30*sec)+"deg)")
mins.css("transform","rotate("+(6*min)+"deg)")
hours.css("transform","rotate("+(30*hour)+"deg)")
</span>}<span style="color: #800000;">
})
</script>
</span></code></pre>
</div>
<p> </p>
</div>
</div>
</div>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.