2016-04-01 17 views
0

ユーザーがボタンに触れるとすぐに自分のモバイルメニューを開くことができます。 offcanvasメニューが表示されているときに両方のボタンでontouchstart = ""を使用してコンテンツにオーバーレイを作成し、いずれかのボタンに触れるとすぐに機能します。 https://londontradition.comウェブサイト:https://londontradition.com、すぐにメニューボタンをタッチすると、オーバーレイが見えるようになります。これは、href = "javascript:void(0) 。。あなたの指を持ち上げまで、ただし、メニュー遷移が開始されませんすべてのヘルプは、おかげで高く評価されボタンを即座に開く

この作品どこの例はここにある:ここで

https://www.ssense.com/が私のメニューの閉じるボタンのhtmlです:

<a href="javascript:void(0);" class="mobile-button visible-sm visible-xs" id="close-btn" ontouchstart="document.getElementById('content').style.cssText = 'opacity:1;';">Menu</a> 

ここに私のメニューのボタンを開くためのhtmlがあります:

<div class="col-sm-3 col-xs-3"><a href="javascript:void(0);" class="mobile-button" id="menu-toggle" ontouchstart="document.getElementById('content').style.cssText = 'opacity:0.1;';">Menu</a></div> 

答えて

0

ontouchstartの代わりにonmouseoverイベントを使用してください。詳細はhereをご覧ください。さらに、マウスがonmouseoutを介してもはやホバリングしていないときに、それを通常に戻す機能を実装する必要があります。私も答えを探している人のためのソリューション自分自身を発見した

<a href="javascript:void(0);" class="mobile-button visible-sm visible-xs" id="close-btn" onmouseover="document.getElementById('content').style.cssText = 'opacity:1;';" onmouseout="document.getElementById('content').style.cssText = 'opacity:0.1;';">Menu</a> 
+0

こんにちは、あなたは私の質問を誤解しているかもしれません。 ontouchstart = ""は作業中の部分で、オーバーレイが表示されます。私はこれを "href =" javascript:void(0); "でオーバーレイと同じように動作させたいと思います。 –

0

これはあなたのコードは次のようになります方法です。

は私がやったことは私のメニューオープンボタンにこれを追加しました:

ontouchstart="document.getElementById('sidebar').style.cssText = 'transform: translateX(0px) !important;';document.getElementById('wrapper').style.cssText = 'transform: translateX(225px) !important;';document.getElementById('top-bar').style.cssText = 'transform: translateX(225px) !important;';document.getElementById('content').style.cssText = 'opacity:0.2;';" 

をして、この私のメニューに[閉じる]ボタン:

ontouchstart="document.getElementById('sidebar').style.cssText = 'transform: translateX(-225px) !important;';document.getElementById('wrapper').style.cssText = 'transform: translateX(0px) !important;';document.getElementById('top-bar').style.cssText = 'transform: translateX(0px) !important;';document.getElementById('content').style.cssText = 'opacity:1;';" 

とすぐに、ユーザが自分の指でボタンに触れると、指を離す前に、メニューが表示されます。

関連する問題