這個可以通過絕對定位,配合left設(shè)置 或者translate去實(shí)現(xiàn)
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、小程序設(shè)計(jì)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了白塔免費(fèi)建站歡迎大家使用!
left的方法:
比如讓class為menu的元素寬為300px,高100%的,設(shè)置left為-300px;在這期間可以加一個過渡transition:left 0.3s ...;
然后讓class為menu active的元素設(shè)置 left設(shè)置為0就可以了 ,在這期間可以加一個過渡transition:left 0.3s ...;
然后可以通過Jquery的toggleClass('active');來實(shí)現(xiàn)切換
translate
比如讓class為menu的元素寬為300px,高100%的,設(shè)置left為-300px;在這期間可以加一個過渡transition:left 0.3s ...;
然后讓class為menu active的元素設(shè)置 transform:translate3d(-300px,0,0) ,在這期間可以加一個過渡transition:left 0.3s ...;
然后可以通過Jquery的toggleClass('active');來實(shí)現(xiàn)切換
這個過程中 需要注意 body需要overflow:hidden; (不然會有滾動條,可設(shè)置overflow-x即可)
left 和 translate 最好用translate ,translate3d可以開啟GPU硬件加速,性能會更好,體驗(yàn)會更流暢
我github有類似小組件樣式
github: IFmiss
希望能解決你的問題
給你一個JQ的三級聯(lián)動:
!doctype?html
html
head
title/title
meta?charset?=?"utf-8"/
/head
style
/style
body
select?id="one"
option?value=""請選擇省份/option
/select
select?id="two"
option?value=""請選擇城市/option
/select
select?id="three"
option?value=""請選擇區(qū)域/option
/select
script?type="text/javascript"?src="js/jquery-1.12.0.js"/script
script?type="text/javascript"
/*
1.搭建框架
2.給省份和城市綁定change事件
*/
$(function(){
var?province?=?[
{"name"?:?"廣東省"?,
"city"?:?[
{
"name"?:?"廣州市"?,
"area"?:?["越秀區(qū)","荔灣區(qū)","海珠區(qū)","天河區(qū),白云區(qū)"]
},
{
"name"?:?"深圳市"?,
"area"?:?["福田區(qū)","羅湖區(qū)","南山區(qū)","寶安區(qū)","龍崗區(qū)"]
}
]
},
{"name"?:?"浙江省"?,
"city"?:?[
{
"name"?:?"杭州市"?,
"area"?:?["上城區(qū)","下城區(qū)","江干區(qū)","西湖區(qū)"]
},
{
"name"?:?"麗水"?,
"area"?:?["蓮都區(qū)","松陽縣","遂昌縣","云和縣"]
}
]
},
{"name"?:?"江西省"?,
"city"?:?[
{
"name"?:?"南昌市"?,
"area"?:?["東湖區(qū)","西湖區(qū)","青云譜區(qū)","灣里區(qū)"]
},
{
"name"?:?"九江市"?,
"area"?:?["潯陽區(qū)","廬山區(qū)","瑞昌市","九江縣"]
},
{
"name"?:?"贛州市"?,
"area"?:?["章貢區(qū)","南康區(qū)","上猶縣","贛縣"]
}
]
},
];
//?二級聯(lián)動
$("#two").change(function(){
var?one_index?=?$("#one?option:selected").index();
var?two_index?=?$("#two?option:selected").index();
var?three?=?$("#three");
three.empty().append("option請選擇區(qū)域/option");
if(two_index??0){
var?area?=?province[one_index-1].city[two_index-1].area;
for(var?i?=?0?;?i??area.length?;?i++){
three.append("option"+area[i]+"/option");
}
}
});
//?一級聯(lián)動
$("#one").change(function(){
var?one_index?=?$("#one?option:selected").index();
var?two?=?$("#two");
console.log(one_index)
two.empty().append("option請選擇城市/option");
$("#three").empty().append("option請選擇區(qū)域/option");//清除
if(one_index??0){
var?city?=?province[one_index-1].city;
console.log(province[one_index-1].city)
for(var?i?=?0?;?i??city.length?;?i++){
two.append("option"+city[i].name+"/option");
}
}
});
init();
function?init(){
for(var?i?=?0?;?i??province.length?;?i++){
$("#one").append("option"+province[i].name+"/option");
}
}
});
/script
/body
/html
1)、普通下拉列表菜單
html代碼如下:
form?action=""?method="get"?
label1、普通下拉列表菜單/label?
select?name=""?
option?value="0"DIVCSS5/option?
option?value="1"DIVCSS5/option?
/select?
/form?
2)、跳轉(zhuǎn)下拉列表菜單(如常見點(diǎn)擊后跳轉(zhuǎn)到選擇網(wǎng)站)
常常一些網(wǎng)站做友情鏈接,與部門之間使用select下拉標(biāo)簽實(shí)現(xiàn)網(wǎng)址跳轉(zhuǎn)。下面我們通過代碼與案例接受select跳轉(zhuǎn)菜單應(yīng)用。
跳轉(zhuǎn)菜單html代碼如下:
form?action=""?method="get"?
label2、跳轉(zhuǎn)的下拉列表菜單/label?
select?name="jumpMenu"?id="jumpMenu"
onchange="MM_jumpMenu('parent',this,0)"?
option?value=""Rothur/option?
option?value=""Rothur/option?
/select?
/form?
實(shí)現(xiàn)跳轉(zhuǎn)還需要在head標(biāo)簽內(nèi)加入Js腳本動作代碼:
script?type="text/javascript"?!--?function?MM_jumpMenu(targ,selObj,restore){?//v3.0?eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");?if?(restore)?selObj.selectedIndex=0;?}?//--?/script
!doctype?html
html?lang="en"
head
meta?charset="UTF-8"
meta?name="viewport"
content="width=device-width,?user-scalable=no,?initial-scale=1.0,?maximum-scale=1.0,?minimum-scale=1.0"
meta?http-equiv="X-UA-Compatible"?content="ie=edge"
titleTEST/title
style
h1{
margin:?0;
}
body{
margin:?0;
height:?100%;
background-color:?#f3f3f3;
}
.header?{
padding:?15px?0;
background-color:?#fff;
border-bottom:?1px?solid?#ccc;
text-align:?center;
width:?100%;
}
.fiexd?.header{
position:?fixed;
top:?0;
}
.fiexd?ul{
margin-top:?84px;
}
/style
/head
body
ul
li
h2列表?1/h2
/li
li
h2列表?2/h2
/li
li
h2列表?3/h2
/li
li
h2列表?4/h2
/li
li
h2列表?5/h2
/li
li
h2列表?6/h2
/li
li
h2列表?7/h2
/li
li
h2列表?8/h2
/li
/ul
div?class="header"h1我是一個標(biāo)題/h1/div
ul
li
h2列表?1/h2
/li
li
h2列表?2/h2
/li
li
h2列表?3/h2
/li
li
h2列表?4/h2
/li
li
h2列表?5/h2
/li
li
h2列表?6/h2
/li
li
h2列表?7/h2
/li
li
h2列表?8/h2
/li
li
h2列表?9/h2
/li
li
h2列表?10/h2
/li
li
h2列表?11/h2
/li
li
h2列表?12/h2
/li
li
h2列表?13/h2
/li
li
h2列表?14/h2
/li
li
h2列表?15/h2
/li
/ul
script
var?header?=?document.getElementsByClassName('header')[0];
var?body?=?document.body;
window.onscroll?=?function?()?{
var?scrollTop?=?document.documentElement.scrollTop?||?document.body.scrollTop;
console.log(scrollTop);
if(scrollTop??100)?{
body.className?=?'fiexd';
}?else?{
body.className?=?'';
}
}
/script
/body
/html
一共有4種側(cè)滑動畫特效。這款CSS3菜單的特點(diǎn)是鼠標(biāo)劃過時即可以各種動畫方式展開和隱藏菜單項(xiàng),該動畫方式由CSS3中的transition-delay屬性來完成
style type="text/css"
/*Fontawesome Iconfont*/
@import url();
@import url();
* {margin: 0; padding: 0;}
li {list-style-type: none;}
.grid {float: left;width:980px;margin: 0 auto;}
.grid li { width: 285px; height: 500px; overflow: hidden; float: left; margin: 20px 0 20px 30px; position: relative; }
.grid li:hover {box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.5);}
.gridli section {position: relative; transition: all 0.25s; width: 100%;}
.gridli h2 {font: bold 14px montserrat; color: #fff; text-transform: uppercase; position: absolute; text-align: center; width: 60%; left: 20%; top: 100px; padding: 10px 0; border: 2px solid white; border-radius: 4px;}
.sidenav { position: absolute; top: 0; left: 0; bottom: 0; background: linear-gradient(rgba(50,60,60, 1), rgba(50,60,60, 0.7)); width: 50px; transition: all 0.25s; overflow: hidden; padding-top: 100px;}
.sidenav li { _overflow: hidden; width: 150px; }
.sidenav a { text-decoration: none; color: #eee; display: block; line-height: 48px; }
.sidenav span {display: block;}
.sidenav b { padding-left 10px; display: block; color: white; font-family: Montserrat; font-size: 12px; line-height: 4; opacity: 0; }
.sidenav a i { display: block; float: left; font-size: 16px; line-height: 48px; width: 50px; text-align: center; }
/*All instances*/
.gridli:hover .sidenav {width: 150px;}
.gridli:hover section {margin-left: 150px;}
.gridli:hover b {opacity: 1;}
.sidenav li:nth-child(1) b, .sidenav li:nth-child(1) a {transition-delay: .08s;}
.sidenav li:nth-child(2) b, .sidenav li:nth-child(2) a {transition-delay: .16s;}
.sidenav li:nth-child(3) b, .sidenav li:nth-child(3) a {transition-delay: .24s;}
.sidenav li:nth-child(4) b, .sidenav li:nth-child(4) a {transition-delay: .32s;}
.sidenav li:nth-child(5) b, .sidenav li:nth-child(5) a {transition-delay: .40s;}
.sidenav li:nth-child(6) b, .sidenav li:nth-child(6) a {transition-delay: .48s;}
/*Three*/
.three .w {transform: perspective(100px) translateZ(-24px);}
.three b {transform: perspective(100px) rotateY(180deg) translateZ(24px) scale(0.5); }
.three:hover b {transform: perspective(100px) rotateY(0) translateZ(24px) scale(1); transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); background: transparent;}
.three .sidenav {width: 150px;}
/*Two*/
.two .w {transform: perspective(100px) translateZ(-24px);}
.two b {transform: perspective(100px) rotateX(90deg) translateZ(24px) scale(1.5); opacity: 0; }
.two:hover b {transform: perspective(100px) rotateX(0) translateZ(24px) scale(1); transition: all .4s; opacity: 1;}
.two .sidenav {width: 150px;}
/*One*/
.one .w {transform: perspective(100px);}
.one b {transform: perspective(100px) rotateY(90deg); _opacity: 0; transform-origin: left center; _border: 1px solid white;}
.one:hover b {transform: perspective(100px) rotateX(0); transition: all .4s; opacity: 1;}
.one .sidenav {width: 150px;}
.one .sidenav span {float: left; width: 100px;}
/style
!--[if IE]
script src=""/script
![endif]--
/head
body
div class="htmleaf-container"
header class="htmleaf-header bgcolor-11"
div class="htmleaf-demo center"
a href="index.html"DEMO1/a
a href="index2.html" class="current"DEMO2/a
a href="index3.html"DEMO3/a
a href="index4.html"DEMO4/a
/div
div style="text-align:center;clear:both;"
script src="/gg_bd_ad_720x90.js" type="text/javascript"/script
script src="/follow.js" type="text/javascript"/script
/div
/header
div class="htmleaf-content bgcolor-8"
ul class="grid"
li class="one"
ul class="sidenav"
liai class="fa fa-check"/ispan class="w"bTasks/b/span/a/li
liai class="fa fa-inbox"/ispan class="w"bMessages/b/span/a/li
liai class="fa fa-pencil"/ispan class="w"bNew Post/b/span/a/li
liai class="fa fa-cog"/ispan class="w"bSettings/b/span/a/li
liai class="fa fa-star"/ispan class="w"bStarred/b/span/a/li
liai class="fa fa-power-off"/ispan class="w"bLogout/b/span/a/li
/ul
section
h2Door Opening/h2
img src="img/mb1.png"/
/section
/li
li class="two"
ul class="sidenav"
liai class="fa fa-check"/ispan class="w"bTasks/b/span/a/li
liai class="fa fa-inbox"/ispan class="w"bMessages/b/span/a/li
liai class="fa fa-pencil"/ispan class="w"bNew Post/b/span/a/li
liai class="fa fa-cog"/ispan class="w"bSettings/b/span/a/li
liai class="fa fa-star"/ispan class="w"bStarred/b/span/a/li
liai class="fa fa-power-off"/ispan class="w"bLogout/b/span/a/li
/ul
section
h2Flip Down/h2
img src="img/mb2.png"/
/section
/li
li class="three"
ul class="sidenav"
liai class="fa fa-check"/ispan class="w"bTasks/b/span/a/li
liai class="fa fa-inbox"/ispan class="w"bMessages/b/span/a/li
liai class="fa fa-pencil"/ispan class="w"bNew Post/b/span/a/li
liai class="fa fa-cog"/ispan class="w"bSettings/b/span/a/li
liai class="fa fa-star"/ispan class="w"bStarred/b/span/a/li
liai class="fa fa-power-off"/ispan class="w"bLogout/b/span/a/li
/ul