以下是 html5 svg秒表电子计时器特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>html5 svg�����Ӽ�ʱ��</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/knockout-2.2.1.js"></script>
<script type="text/javascript" src="js/sevenSeg.js"></script>
<script type="text/javascript" src="js/demo.js"></script>
<style type="text/css">
*{height: 100%;}
body{margin: 0;overflow: hidden;}
</style>
</head>
<body>
<div id="testResizableArray"></div>
</body>
</html>
JS代码(demo.js):
$(function (){
var viewModel ={
mainExampleValue:ko.observable(-5.234),testValue1:ko.observable(-12.4),testValue2:ko.observable(9876)}
;
ko.applyBindings(viewModel);
$("#exampleSingle").sevenSeg({
value:5}
);
$("#exampleArray").sevenSeg({
digits:5,value:12.35}
);
setInterval(function(){
var value = +viewModel.mainExampleValue() + 0.001;
viewModel.mainExampleValue(value.toFixed(3));
}
,100);
$("#testResizableDiv").resizable({
aspectRatio:true}
);
$("#testSegInsideResizable").sevenSeg({
value:8}
);
$("#testResizableArray").sevenSeg({
digits:3}
);
$("#testResizableDiv2").resizable({
aspectRatio:true}
);
var iArrayValue = 0;
setInterval(function(){
$("#testResizableArray").sevenSeg({
value:iArrayValue}
);
if(++iArrayValue > 999){
iArrayValue = 0;
}
}
,50);
$("#testArray1").sevenSeg({
digits:5,value:-98.76,colorOff:"#003200",colorOn:"Lime",slant:10}
);
$("#btnCreate").click(function(){
$("#testArray2").sevenSeg({
digits:4,value:12.34}
);
}
);
$("#btnDestroy").click(function(){
$("#testArray2").sevenSeg("destroy");
}
);
window.prettyPrint && prettyPrint();
}
);