其他分享
首页 > 其他分享> > Canvas与Div层级设置 显示当前时间

Canvas与Div层级设置 显示当前时间

作者:互联网

1,Div放在Canvas上面:

  Div的position设为fixed或absolute

2,鼠标穿透上层的div,操作下层的Canvas

  设置div的pointer-events:none即可

3,Echarts背景图设置:background-image:url('./image.png')

 

4, 显示当前时间 并自动刷新

<script type="text/javascript">
        var t = null;
		t = setInterval("getTime();",1000); //每隔一秒运行一次
	
	    //取得系统当前时间
        function getTime(){
            var myDate = new Date();
            var date = myDate.toLocaleDateString();
            var hours = myDate.getHours();
            var minutes = myDate.getMinutes();
            var seconds = myDate.getSeconds();
            //将值赋给div
            document.getElementById("currentTime").innerHTML = date+" "+hours+":"+minutes+":"+seconds;
        }
    </script>

  

标签:Canvas,层级,getTime,myDate,var,Div,div
来源: https://www.cnblogs.com/kevinN/p/16028983.html