var cv = $(window).width();
function createTimer(widthOf) {
var timer = document.getElementById('timer');
var svg = document.getElementById('svg');
var width = widthOf;
svg.setAttribute('width', width);
svg.setAttribute('height', width);
var t = 5;
var theta = 0;
var radius = svg.getAttribute('width')/2;
timer.setAttribute('transform', 'translate(' + radius + ',' + radius + ')');
(function animate() {
theta += 0.5;
theta %= 360;
var x = Math.sin(theta * Math.PI/180) * radius;
var y = Math.cos(theta * Math.PI/180) * -radius;
var d = 'M0,0 v' + -radius + 'A' + radius + ',' + radius + ' 1 ' + ((theta > 180) ? 1 : 0) + ',1 ' + x + ',' + y + 'z';
timer.setAttribute('d', d);
setTimeout(animate, t)
})();
}
function createButton(widthOf, top, left) {
$('<a>', {
class: 'round-button',
}).appendTo('#container');
$('.round-button').css({
'height': (widthOf) + 'px',
'width': (widthOf) + 'px',
'top': (top + 8) + 'px',
'left': '50%',
'margin-left': (-widthOf/2) + 'px',
'font-size': (widthOf/3) + 'px',
});
$('<p>', {
text: 'tap',
}).appendTo('.round-button');
}
$("#btn1").click(function() {
createTimer(.8 * cv);
var ml = (.25 * cv)/2;
var mt = (.05 * cv)/2;
createButton((.75 * cv), mt, ml);
});
body {
background: skyBlue;
text-align: center;
}
#svg {
position: relative;
z-index: 0;
}
#overlay {
position: absolute;
left: 20%;
z-index: 5;
background-color: green;
width: 60%;
height: 30px;
top: 5px;
}
.round-button {
position: absolute;
width: 400px;
z-index: 9999999;
display: block;
width: 500px;
height: 500px;
line-height: 50px;
border: 5px solid #f5f5f5;
border-radius: 50%;
color: #f5f5f5;
text-align: center;
text-decoration: none;
background: #464646;
box-shadow: 0 0 3px gray;
font-size: 20px;
font-weight: bold;
box-sizing: border-box;
}
.round-button p {
vertical-align: middle;
}
.round-button:focus {
background: #262626;
position: absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="container">
<svg id="svg">
<path id="timer" fill="#66ff66" />
</svg>
</div>
<button id="btn1">start</button>
하 석 그 코드가 익숙 Updated Fiddle
. –
예, @ chipChocolate.py 그는 Z- 색인 질문을 더 일찍 요청 했습니까? –
@Godisgood - 아니, 나는 그의 게시물 중 하나에 어제 그것을 (http://stackoverflow.com/a/27666168/3905567) 대답했다. –