首页上一页 1 下一页尾页 1 条记录 1/1页
javascript
发表在JavaScript答疑区
2016-08-16
是否精华
是
否
版块置顶:
是
否
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
#div1{
width: 100px;
height: 200px;
background-color: red;
position:absolute;
top: 100px;
left: -100px;
}
#div2{
width: 30px;
height: 60px;
position: absolute;
top: 70px;
right: -30px;
background-color: black;
color: white;
text-align: center;
}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById('div1');
oDiv.onmouseover = function(){
this.style.left="0px";
}
oDiv.onmouseout = function(){
this.style.left="-100px";
}
</script>
</head>
<body>
<div id="div1">
<div id="div2">分享到</div>
</div>
</body>
</html>
为什么没有效果啊
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
#div1{
width: 100px;
height: 200px;
background-color: red;
position:absolute;
top: 100px;
left: -100px;
}
#div2{
width: 30px;
height: 60px;
position: absolute;
top: 70px;
right: -30px;
background-color: black;
color: white;
text-align: center;
}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById('div1');
oDiv.onmouseover = function(){
this.style.left="0px";
}
oDiv.onmouseout = function(){
this.style.left="-100px";
}
</script>
</head>
<body>
<div id="div1">
<div id="div2">分享到</div>
</div>
</body>
</html>
为什么没有效果啊