2014-12-02 53 views
0

我有這個菜單http://meetsingledating.com/test/。當我點擊按鈕「M」時,菜單從左邊推。手機左推菜單

我不想按鍵「M」是灰色的色調,當菜單打開時,我想它是這樣的:

http://meetsingledating.com/test/2.jpg

而當菜單是開放的,我點擊按鈕「M」,我想菜單關閉時灰色的色調相同的方式。

我已經嘗試了更高的z-index和按鈕的位置,但它不起作用。

感謝您的幫助。

+0

請在問題相關的代碼。 – jurgemaister 2014-12-02 12:45:05

回答

0

這將工作:

刪除此:

#wrapper { 
    z-index:10; // <--- remove this 
} 

補充一點:

.buttons button { 
    z-index: 16; // <--- 
    position: relative; // <--- 
} 

DEMOhttp://jsfiddle.net/MarkkNijboer/e6ngmgfg/


UPDATE:

我改變了功能按鈕了一下。現在檢查菜單是否打開與否:

/* push menu left */ 
togglePushLeft.addEventListener("click", function(){ 
    if(classie.has(body, "pml-open")) { 
     classie.remove(body, activeNav); 
     activeNav = ""; 
     document.body.removeChild(mask); 
    } else { 
     classie.add(body, "pml-open"); 
     document.body.appendChild(mask); 
     activeNav = "pml-open"; 
    } 
}); 

DEMOhttp://jsfiddle.net/MarkkNijboer/e6ngmgfg/1/

+0

它的工作原理,謝謝。問題是當菜單打開時,我點擊按鈕「M」它仍然打開,它應該關閉。 – 2014-12-02 13:17:54

+0

@AdrienParad我更新了我的答案。現在它可以工作。 – 2014-12-02 13:26:06

+0

感謝它的工作。但是有沒有辦法離開z-index:10;在包裝上,並使按鈕出現?謝謝。 – 2014-12-02 13:50:25

0

嘗試SIDR http://www.berriart.com/sidr/ 這是一個jQuery插件能夠實現此功能。它也是可定製的。 基本用法

`

<a id="existing-content-menu" href="#existing-content-menu">Existing content</a> 
<a id="remote-content-menu" href="#remote-content-menu">Load remotelly</a> 
<a id="callback-menu" href="#callback-menu">Callback loaded</a> 

<header id="demoheader"> 
<h1>Demos &amp; Usage</h1> 
</header> 

<div id="demo-content"> 
<p>Here are described differents ways of usage for this plugin, you can read and adapt them to your website's requeriments. Below are described all options with details.</p> 
</div> 

<script> 
$(document).ready(function() { 
$('#existing-content-menu').sidr({ 
name: 'sidr-existing-content', 
source: '#demoheader, #demo-content' 
}); 
$('#remote-content-menu').sidr({ 
name: 'sidr-remote-content', 
source: 'http://www.example.com/remote-menu.html' 
}); 
$('#callback-menu').sidr({ 
name: 'sidr-callback', 
source: function(name) { 
return '<h1>' + name + ' menu</h1><p>Yes! You can use a callback too ;)</p>'; 
} 
}); 
}); 
</script> 

`