首页 技术 正文
技术 2022年11月23日
0 收藏 625 点赞 2,291 浏览 1385 个字
<!doctype html>
<html>
<head>
<meta charset = "utf-8">
<title>未命题</title>
<style>
*{margin: 0;
padding: 0;
}
#div1{
height: 200px;
width: 150px;
background: red;
position:absolute;
top:50px;
left: -150px;
}
#div2{
height: 50px;
width: 20px;
background: black;
color: white;
position:absolute;
top:100px;
right:-20px;
line-height: 25px;
cursor: pointer;
}
img{
margin-left: 200px;
opacity: 0.3;
alpha(opacity = 30);
}
</style>
<script>
window.onload = function ()
{
odiv1 = document.getElementById('div1');
odiv2 = document.getElementById('div2');
oimg = document.getElementById('img1'); odiv1.onmouseover= function ()
{
startMove(this,'left',0,10);
} odiv1.onmouseout = function ()
{
startMove(this,'left',-150,-10);
} oimg.onmouseover = function ()
{ startMove(this,'opacity',100,10);
} oimg.onmouseout = function ()
{
startMove(this,'opacity',30,-10);
} function startMove (obj,attr,goal,speed)
{
clearInterval(obj.timer);
var icur = 0; obj.timer = setInterval(function(){
if(attr == 'opacity')
{
icur = Math.round(css(obj,'opacity')*100);
}
else
{
icur = parseInt(css(obj,attr))
} if(icur == goal)
{
clearInterval(obj.timer);
}
else
{
if(attr == 'opacity')
{
obj.style.opacity = (icur + speed )/100;
obj.style.filter = 'alpha(opacity = '+ (icur + speed ) +')';
}
else
{
obj.style[attr] = icur + speed + 'px';
}
}
},30);
} function css(obj,attr)
{
if(obj.currentStyle)
return obj.currentStyle[attr];
else
return getComputedStyle(obj,false)[attr];
} }
</script>
</head>
<body> <div id="div1"><div id="div2">分享</div></div>
<img id="img1" src = "img/1.jpg"> </body> </html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:7,948
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:4,824
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:5,651
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:5,517
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:6,718
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,188