用javaScript来实现一个简易绘图板
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#pos{position: absolute;left:20px;bottom: 20px;}
.box{border-radius: 50%;position: absolute;}
input{z-index: 1;position: absolute;}
#add{left: 0;}
#red{left: 50px;}
#color{left: 100px;}
</style>
</head>
<body>
<input type="button" id="add" value="+" />
<input type="button" id="red" value="-" />
<input type="color" id="color" />
<span id="pos"></span>
</body>
<script type="text/javascript">
var opos = document.getElementById("pos");
var w = h = 10;
var c = "black";
document.onmousemove = function(eve){
var e = eve ? eve : window.event;
var div = document.createElement("div");
div.className = "box";
div.style.cssText = "left:"+ e.clientX +"px;top:"+ e.clientY +"px;width:"+ w +"px;height:"+ h +"px;background:"+ c +";"
document.body.appendChild(div);
opos.innerHTML = e.clientX + "," + e.clientY;
}
var oAdd = document.getElementById("add")
var oRed = document.getElementById("red")
var oColor = document.getElementById("color")
oAdd.onclick = function(){
w+=5;
h+=5;
}
oRed.onclick = function(){
if(w <= 5){
w = 5;
h = 5
}else{
w-=5;
h-=5;
}
}
oColor.onchange = function(){
c = this.value;
}
</script>
</html>