js實(shí)現(xiàn)上下左右彈框劃出效果
更新時(shí)間:2017年03月08日 10:13:50 作者:留白snow
本文主要介紹js實(shí)現(xiàn)上下左右彈框劃出效果的實(shí)例,具有很好的參考價(jià)值。下面跟著小編一起來看下吧
效果圖:

圖(1)初始圖

圖(2)點(diǎn)擊“從右側(cè)劃出”
代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<title>上下左右彈框劃出效果</title>
<style>
/*css document*/
body,div,ol,ul,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,p,form,fieldset,legend,input,button,aside{ padding: 0; margin: 0; -webkit-tap-highlight-color:rgba(255,255,255,0);}
body { font-family: "Microsoft YaHei"; }
.btn button {
display: block;
width: 240px;
line-height: 30px;
margin: 20px auto;
background-color: #cd0000;
color: #fff;
text-align: center;
outline: none;
border: none;
cursor: pointer;
font-family: "Microsoft YaHei";
}
.aside,
.aside-overlay {
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.aside {
-webkit-transition: visibility .25s;
transition: visibility .25s;
z-index: 3;
visibility: hidden;
overflow: hidden;
}
.aside > div { text-align: center; }
.aside.active {
-webkit-transition: none;
transition: none;
visibility: visible;
}
.aside-overlay {
background-color: rgb(0,0,0);
opacity: 0;
-webkit-transition: opacity .25s;
transition: opacity .25s;
}
.active > .aside-overlay {
opacity: .6;
}
.rightContent {
position: absolute;
bottom: 0;
right: 0;
top: 0;
left: 40px;
background:#fff;
-webkit-transition: transform .15s;
transition: transform .15s;
-webkit-transform:translateX(100%);
transform:translateX(100%);
}
.active > .rightContent {
-webkit-transform:translateX(0%);
transform:translateX(0%);
}
.leftContent {
position: absolute;
bottom: 0;
right: 40px;
top: 0;
left: 0;
background:#fff;
-webkit-transition: transform .15s;
transition: transform .15s;
-webkit-transform:translateX(-100%);
transform:translateX(-100%);
}
.active > .leftContent {
-webkit-transform:translateX(0%);
transform:translateX(0%);
}
.topContent {
position: absolute;
bottom: 40px;
right: 40px;
top: 0;
left: 40px;
background:#fff;
-webkit-transition: transform .15s,top .15s;
transition: transform .15s;
-webkit-transform:translateY(-100%);
transform:translateY(-100%);
}
.active > .topContent {
top: 40px;
-webkit-transform:translateY(0%);
transform:translateY(0%);
}
.botContent {
position: absolute;
bottom: 0;
right: 40px;
top: 40px;
left: 40px;
background:#fff;
-webkit-transition: transform .15s,bottom .15s;
transition: transform .15s;
-webkit-transform:translateY(100%);
transform:translateY(100%);
}
.active > .botContent {
bottom: 40px;
-webkit-transform:translateY(0%);
transform:translateY(0%);
}
</style>
</head>
<body>
<!-- 按鈕 -->
<div class="btn">
<button id="rightBtn">從右側(cè)劃出</button>
<button id="leftBtn">從左側(cè)劃出</button>
<button id="topBtn">從上面劃下</button>
<button id="botBtn">從下面劃上</button>
</div>
<!-- 彈出層 -->
<aside id="aside" class="aside">
<i class="aside-overlay hideAside"></i>
<div class="rightContent">
右側(cè)劃出
</div>
<div class="leftContent">
左側(cè)劃出
</div>
<div class="topContent">
從上面劃下
</div>
<div class="botContent">
從上面劃下
</div>
</aside>
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
var rightBtn = $('#rightBtn'),leftBtn = $('#leftBtn'),topBtn = $('#topBtn'),botBtn = $('#botBtn');
var oAside = $('#aside');
rightBtn.on("click",function(){
$('.leftContent').hide();
$('.topContent').hide();
$('.botContent').hide();
$('.rightContent').show();
oAside.addClass('active');
});
leftBtn.on("click",function(){
$('.rightContent').hide();
$('.topContent').hide();
$('.botContent').hide();
$('.leftContent').show();
oAside.addClass('active');
});
topBtn.on("click",function(){
$('.rightContent').hide();
$('.leftContent').hide();
$('.botContent').hide();
$('.topContent').show();
oAside.addClass('active');
});
botBtn.on("click",function(){
$('.rightContent').hide();
$('.leftContent').hide();
$('.topContent').hide();
$('.botContent').show();
oAside.addClass('active');
});
$('.hideAside').on("click",function(){
oAside.removeClass('active');
});
})
</script>
</body>
</html>
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!
您可能感興趣的文章:
- js+html5實(shí)現(xiàn)半透明遮罩層彈框效果
- vue.js中toast用法及使用toast彈框的實(shí)例代碼
- js自定義彈框插件的封裝
- 輕松實(shí)現(xiàn)js彈框顯示選項(xiàng)
- vue.js實(shí)現(xiàn)只彈一次彈框
- js重寫alert事件(避免alert彈框標(biāo)題出現(xiàn)網(wǎng)址)
- 基于layer.js實(shí)現(xiàn)收貨地址彈框選擇然后返回相應(yīng)的地址信息
- javascript實(shí)現(xiàn)無法關(guān)閉的彈框
- JavaScript實(shí)現(xiàn)alert彈框效果
- JavaScript封裝彈框插件的方法
相關(guān)文章
js+html+css實(shí)現(xiàn)簡單電子時(shí)鐘
這篇文章主要為大家詳細(xì)介紹了js+html+css實(shí)現(xiàn)簡單電子時(shí)鐘,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06
Javascript操縱Cookie實(shí)現(xiàn)購物車程序
Javascript操縱Cookie實(shí)現(xiàn)購物車程序...2007-02-02
JS使用插件cryptojs進(jìn)行加密解密數(shù)據(jù)實(shí)例
這篇文章主要介紹了JS使用插件cryptojs進(jìn)行加密解密數(shù)據(jù),結(jié)合完整實(shí)例形式分析了javascript基于加密插件實(shí)現(xiàn)加密解密功能的相關(guān)操作技巧,需要的朋友可以參考下2017-05-05
js文件中調(diào)用js的實(shí)現(xiàn)方法小結(jié)
JavaScript文件引用JavaScript文件的方法,需要的朋友可以參考下。2009-10-10
input輸入框限制只能輸入數(shù)字的方法實(shí)例(個(gè)人認(rèn)為最好的)
在很多業(yè)務(wù)中需要對輸入框進(jìn)行字符限制,比如金額輸入框、手機(jī)號碼輸入框等,下面這篇文章主要給大家介紹了關(guān)于input輸入框限制只能輸入數(shù)字的相關(guān)資料,文中介紹的方法個(gè)人認(rèn)為最好的,需要的朋友可以參考下2022-10-10

