1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>transition</title>
<script type="text/javascript"> window.onload = function () { var box = document.getElementById("box"); box.addEventListener("mouseover", function () { this.style.opacity = 1; this.style.height = '50px'; this.style.width = '300px'; this.style.backgroundColor = 'blue'; this.style.borderRadius = '5px'; this.style.boxShadow = '2px 2px 6px blue'; }) box.addEventListener("mouseout", function () { this.style.opacity = 0.5; this.style.height = '150px'; this.style.width = '150px'; this.style.backgroundColor = "blue"; this.style.borderRadius = "50%"; this.style.boxShadow = '0px 0px 0px ';
})
var circle = document.getElementById("circle") circle.addEventListener("mouseover", function () { this.style.borderRadius = "0"; this.style.backgroundColor = "#c847c8" }) circle.addEventListener("mouseout", function () { this.style.borderRadius = "50%"; this.style.backgroundColor = "purple" }) }
</script> <style type="text/css"> .box { height: 150px; width: 150px; background-color: red; opacity: 0.5; transition: opacity 1s, height 1s, width 1.8s, background-color 1s, border-radius 1s, box-shadow 2s; display: inline-block; }
.circle { height: 150px; width: 150px; border-radius: 50%; background-color: purple; display: inline-block; opacity: 0.6; transition: background-color 1s, border-radius 1.5s; } </style> </head>
<body> <div class="box" id="box"></div> <div class="circle" id="circle"></div>
</body>
</html>
|