简体   繁体   English

像JQuery Mobile这样的Javascript菜单

[英]Javascript Menu like JQuery Mobile

I'm working with Firefox OS, on customer requirements I can not use frameworks for JavaScript (like JQuery), ie everything must be html, css and JS. 我正在使用Firefox OS,但根据客户要求,我无法使用JavaScript框架(如JQuery),即所有内容都必须为html,css和JS。

I have to do the pull-down menu with the same side effect of "pushing the page" ( this one ) we've seen in JQuery Mobile. 我必须做下拉菜单,其副作用与我们在JQuery Mobile中看到的“推页面”( 这一点 )相同。

They know how I can do this effect? 他们知道我该怎么做?

Thanks a lot 非常感谢

A basic way of doing this is to create a div box (page) and set a z-index lower than the main page so its always behind the main page. 一种基本方法是创建一个div框(页面),并将z-index设置为低于主页,以便使其始终位于主页之后。 Then using css you can move the main page up and down to reveal the page behind. 然后,使用css可以上下移动主页以显示后面的页面。

CSS 的CSS

#page {
    z-index: 999;
    width:100%;
    height:100%;
    background-color:white;
    position:fixed;
    top:0;
    left: 0;
    -webkit-transition: all .5s ease;
}

.box {
    position:fixed;
    top:0;
    left: 0;
    height:100%;
    background-image: linear-gradient(#ddd, #ccc);
    width: 100%;
    display: block;
    z-index:1;
}

.move {
    top: 0em;
    margin-top:10em;
}
.moveb {
    top: 0em;
    margin-top:0em;
}

JavaScript 的JavaScript

function doMove() {
 var element = document.getElementById("page");
 element.classList.remove("move");
 element.classList.remove("moveb");
 element.classList.add("move");
}

function doMoveb() {
 var element = document.getElementById("page");
 element.classList.remove("move");
 element.classList.remove("moveb");
 element.classList.add("moveb");
}      

Demo 演示版

http://jsfiddle.net/cut3y0sq/ http://jsfiddle.net/cut3y0sq/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM