1.2鼠标移入移出改变背景色和其他大小样式

功能:鼠标移入div,背景色变为绿色,宽变小,长变大,移出恢复原状

事件:onmouseover,onmouseout

属性: background,width,height

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">


<link href="css1.css" rel="stylesheet" type="text/css"
charset="UTF-8">
</head>
<body>
<div id="div1"></div>


<script src="js1.js"> </script>
</body>
</html>

/////////////////////////css


#div1{
width:100px;
height:200px;
background: red;
}

//////////////////////////js

var oDiv=document.getElementById("div1")
oDiv.onmouseover=function(){
oDiv.style.background = 'green';
oDiv.style.width = '200px';
oDiv.style.height = '100px';
};
oDiv.onmouseout=function(){
oDiv.style.background = 'red';
oDiv.style.width = '100px';
oDiv.style.height = '200px';
};

posted @ 2018-03-03 21:17  萹豆  阅读(257)  评论(0编辑  收藏  举报