JQuery制作的放大效果的popup对话框(未添加任何jquery plugin)分享 - Web前端
作者:98wpeu发布时间:2026-06-27分类:网页前端技术浏览:7
导读:多的不说了,直奔主题,分享一个放大效果的popupdialog,项目中可以根据自己的需求来写CSS,我打算复用到Metro风格的site上去。看起来动画效果还是比较cool的,...
多的不说了,直奔主题,分享一个放大效果的popup dialog,项目中可以根据自己的需求来写CSS,我打算复用到Metro风格的site上去。
看起来动画效果还是比较cool的,如果加上了处理后的效果更佳:
复制代码 代码如下:
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/JQuery-1.4.1.min.JS" type="text/javascript"></script>
<style>
body { background: #ace; font: 12px/1.2 Arial, Helvetica, sans-serif; }
ul li { background:#fff; margin:5px; width:100px; height:100px; float:left; }
#transition {
background:transparent;
display:none;
position:absolute; top:50%; left:50%; z-index:50;
z-index: 10001;
}
#content {
background:#fff;
border:1px solid #666;
margin:-50px 0 0 -50px;
width:100px; height:100px;
z-index: 10001;
}
#mask{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000;
display: none;
z-index: 10000;
}
.close
{
width:30px;
height:20px;
background-color:Red;
cursor:pointer;
display:none;
}
.closeShow
{
width:30px;
height:20px;
margin-left:50px;
margin-top:-100px;
background-color:Red;
Cursor:pointer;
}
</style>
<script type="text/JavaScript">
$(document).ready(function () {
$('ul li').click(function (e) {
$("#mask").fadeTo(500, 0.25);
$("#content").HTML("<div>loading....</div>");
var $t = $('#transition'),
to = $(this).offset();
var height = $(document).height();
var width = $(document).width();
$('#content').css({ width: 100, height: 100 });
$t.css({
top: to.top + 50,
left: to.left + 50,
display: 'block'
}).Animate({
top: height / 2,
left: width / 2
}, 600, function () {
$(this).animate({
top: 125,
left: 175
}, 600);
$('#content').animate({
width: width * 0.8,
height: height * 0.8
}, 600, function () {
// open dialog here
$("#content").html("<div>Hello, please put content here.</div>");
});
});
});
$('#transition').click(function (e) {
$("#transition").hide();
$("#mask").hide();
});
});
</script>
</head>
<body>
<FORM id="form1" runat="server">
<ul>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
</ul>
<div id='mask'></div>
<div id="transition"><div id="content">loading....</div></div>
</Form>
</body>
</html>
加入了mask效果,如果不需要可以直接删掉。
看起来动画效果还是比较cool的,如果加上了处理后的效果更佳:
复制代码 代码如下:
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/JQuery-1.4.1.min.JS" type="text/javascript"></script>
<style>
body { background: #ace; font: 12px/1.2 Arial, Helvetica, sans-serif; }
ul li { background:#fff; margin:5px; width:100px; height:100px; float:left; }
#transition {
background:transparent;
display:none;
position:absolute; top:50%; left:50%; z-index:50;
z-index: 10001;
}
#content {
background:#fff;
border:1px solid #666;
margin:-50px 0 0 -50px;
width:100px; height:100px;
z-index: 10001;
}
#mask{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000;
display: none;
z-index: 10000;
}
.close
{
width:30px;
height:20px;
background-color:Red;
cursor:pointer;
display:none;
}
.closeShow
{
width:30px;
height:20px;
margin-left:50px;
margin-top:-100px;
background-color:Red;
Cursor:pointer;
}
</style>
<script type="text/JavaScript">
$(document).ready(function () {
$('ul li').click(function (e) {
$("#mask").fadeTo(500, 0.25);
$("#content").HTML("<div>loading....</div>");
var $t = $('#transition'),
to = $(this).offset();
var height = $(document).height();
var width = $(document).width();
$('#content').css({ width: 100, height: 100 });
$t.css({
top: to.top + 50,
left: to.left + 50,
display: 'block'
}).Animate({
top: height / 2,
left: width / 2
}, 600, function () {
$(this).animate({
top: 125,
left: 175
}, 600);
$('#content').animate({
width: width * 0.8,
height: height * 0.8
}, 600, function () {
// open dialog here
$("#content").html("<div>Hello, please put content here.</div>");
});
});
});
$('#transition').click(function (e) {
$("#transition").hide();
$("#mask").hide();
});
});
</script>
</head>
<body>
<FORM id="form1" runat="server">
<ul>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
<li>thumb</li>
</ul>
<div id='mask'></div>
<div id="transition"><div id="content">loading....</div></div>
</Form>
</body>
</html>
加入了mask效果,如果不需要可以直接删掉。
相关推荐
- jQuery提交多个表单的小技巧 - Web前端
- Jquery原生态实现表格header头随滚动条滚动而滚动 - Web前端
- jquery高效反选具体实现 - Web前端
- jquery控制左右箭头滚动图片列表的实例 - Web前端
- JQUERY对单选框(radio)操作的小例子 - Web前端
- JqueryMobile动态生成listView并实现刷新的两种方法 - Web前端
- jquery获取焦点和失去焦点事件代码 - Web前端
- jquery 无限级联菜单案例分享 - Web前端
- jquery+css+ul模拟列表菜单具体实现思路 - Web前端
- jquery的相对父元素和相对文档定位示例代码 - Web前端
- 网页前端技术排行
-
- 1【第六章】Foundation之按钮和下拉功能 - Web前端
- 2jQuery编写widget的一些技巧分享 - Web前端
- 3基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 4jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 5在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 6分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 7[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 8分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 9JS网页制作实例:标签云 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


