CSS变形弹窗效果mphingmodalwindow

所属分类:UI-弹出层

 31309  403  查看评论 (3)
分享到微信朋友圈
X
CSS变形弹窗效果mphingmodalwindow ie兼容9

使用教程

本代码兼容Chrome, Firefox, Safari, Opera,而IE需要9.0或以上版本(IE9+)

STEP 1: 创建HTML布局

<section class="cd-section">
    <!-- section content here -->
    <div class="cd-modal-action">
        <a href="#0" class="btn" data-type="modal-trigger">Fire Modal Window</a> <!? 这是窗体按钮 -->
        <span class="cd-modal-bg"></span>
    </div>
    <div class="cd-modal">
        <div class="cd-modal-content">
        <!? 这是窗体内容区域 -->
        </div>
    </div>
    <a href="#0" class="cd-modal-close">Close</a> <!? 这是关闭按钮 -->
</section>

STEP 2: 添加CSS样式

.cd-modal-action {
	position:relative;
}
.cd-modal-action .btn {
	width:12.5em;
	height:4em;
	background-color:#123758;
	border-radius:5em;
	transition:color 0.2s 0.3s,width 0.3s 0s;
}
.cd-modal-action .btn.to-circle {
	width:4em;
	color:transparent;
	transition:color 0.2s 0s,width 0.3s 0.2s;
}
.cd-modal-action .cd-modal-bg {
	position:absolute;
	top:0;
	left:50%;
	transform:translateX(-2em);
	width:4em;
	height:4em;
	background-color:#123758;
	border-radius:50%;
	opacity:0;
	visibility:hidden;
	transition:visibility 0s 0.5s;
}
.cd-modal-action .cd-modal-bg.is-visible {
	opacity:1;
	visibility:visible;
}

STEP 3: 添加jQuery

本代码使用了jQuery,你可以通过下面代码来修改窗口大小。

var btnRadius = $('.cd-modal-bg').width() / 2,
left = $('.cd-modal-bg').offset().left + btnRadius,
top = $('.cd-modal-bg').offset().top + btnRadius - $(window).scrollTop(),
scale = scaleValue(top, left, btnRadius, $(window).height(), $(window).width());
function scaleValue(topValue, leftValue, radiusValue, windowW, windowH) {
    var maxDistHor = (leftValue > windowW / 2) ? leftValue: (windowW - leftValue),
    maxDistVert = (topValue > windowH / 2) ? topValue: (windowH - topValue);
    return Math.ceil(Math.sqrt(Math.pow(maxDistHor, 2) + Math.pow(maxDistVert, 2)) / radiusValue);
}


相关插件-弹出层

jQuery图像展示插件Strip

Strip是Lightbox的一种,它只能部分覆盖页面。这样就不会占用大的屏幕面积,适用于比较小的移动设备
  弹出层
 32044  391

jQuery弹出层插件(原创)

简约的jQuery弹出层插件
  弹出层
 25689  243

表格鼠标移入同行同列变色(原创)

jQuery表格鼠标移入后同行同列变色
  弹出层
 26114  320

响应式模态框

简洁、弹出效果好的响应式模态框,适用移动端
  弹出层
 36511  436

讨论这个项目(3)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    拖鞋 0
    2016/3/24 16:03:33
    这个不错挺酷炫的
        小雪花19450
        2016/3/28 11:03:21
        这个效果很棒
        放开那女孩 0
        2016/8/9 13:08:32
        很实用的
    回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复