猿问

Jquery元素居中放大效果,求指教思路谢谢?

页面中已经有一个DIV了,并且始终保持居中状态的,我想让它从0开始慢慢放大,这个过程要始终居中显示,请教下各位大侠重点在哪儿?若能有实例代码就更好了O(∩_∩)O~先谢啦!

摇曳的蔷薇
浏览 525回答 1
1回答

30秒到达战场

jQuery实现很简单啊,写了个demo给你<html><head>&nbsp; &nbsp; <meta charset="UTF-8">&nbsp; &nbsp; <title>Document</title>&nbsp; &nbsp; <script src="//localhost/jquery-3.1.0.min.js"></script>&nbsp; &nbsp; <style>&nbsp; &nbsp; &nbsp; &nbsp; .wrap { position: relative; width: 500px; height: 500px; background-color: #eee; }&nbsp; &nbsp; &nbsp; &nbsp; .wrap div{ position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); -webkit-transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%); width: 0px; height: 0px; background-color: red; }&nbsp; &nbsp; </style></head><body>&nbsp; &nbsp; <div class="wrap">&nbsp; &nbsp; &nbsp; &nbsp; <div></div>&nbsp; &nbsp; </div></body><script>$(function(){&nbsp; &nbsp; $('.wrap div').animate({height:'500px', width:'500px'},2000);})</script></html>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答