您的位置:首页 > Web前端 > JQuery

jquery点击单张图片放大效果

2016-10-27 10:29 591 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>单图放大</title>
<link rel="stylesheet" href="css/lrty/lrtk.css" />
<script type="text/javascript" src="js/jquery/jquery-1.11.1.min.js" ></script>
<style type="text/css">
#div1{ width:600px; height:400px; margin:50px auto; position:relative;  text-align: center; padding-left:50px;}
#div1 img{ position:absolute; left:0; top:0; margin: 0 auto;}
</style>
<script type="text/javascript">
$(function(){
$('#div1 img').mouseenter(function(){
var wValue=1.5 * $(this).width();
var hValue=1.5 * $(this).height();
$(this).stop().animate({width: wValue,
height: hValue,
left:("-"+(0.5 * $(this).width())/2),
top:("-"+(0.5 * $(this).height())/2)}, 1000);
}).mouseleave(function(){
$(this).stop().animate({width: "100",
height: "80",
left:"0px",
top:"0px"}, 1000 );
});
});
</script>
</head>
<body>
<div id="div1">
<img src="images/01.jpg" width="100px" height="80px"/>
</div>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: