JS里脱离文档流
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
img
{
position:absolute;/*完全脱离*/
width:200px;
height:150px;
}
</style>
<script type="text/javascript">
onload = function () {
//第一步 脱离文档流
//第二步 设置事件
document.onmousemove = function () {
//第三步 设置坐标
//获取图片
var imObj = document.getElementById('im');
imObj.style.left = window.event.clientX + 'px';
imObj.style.top = window.event.clientY + 'px';
};
};
</script>
</head>
<body>
<img src="1.gif" id="im" />
</body>
</html>
<head>
<title></title>
<style type="text/css">
img
{
position:absolute;/*完全脱离*/
width:200px;
height:150px;
}
</style>
<script type="text/javascript">
onload = function () {
//第一步 脱离文档流
//第二步 设置事件
document.onmousemove = function () {
//第三步 设置坐标
//获取图片
var imObj = document.getElementById('im');
imObj.style.left = window.event.clientX + 'px';
imObj.style.top = window.event.clientY + 'px';
};
};
</script>
</head>
<body>
<img src="1.gif" id="im" />
</body>
</html>