jQuery mobile 滑動開啟面板

來源:互聯網
上載者:User

標籤:url   iphone   rip   bsp   button   image   ane   body   iphone6   

一、首先在<head></head>裡面引入jQuery庫、jQuery mobile庫以及jQuery mobile樣式

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /><script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script><script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

 

二、建立一個(左/右側)面板

<body>          <div data-role="page" id="page" style="max-height:440px; min-height:440px;">         <div data-role="header">         </div>         <div data-role="content">              <a href="#defaultpanel" data-role="button" data-inline="true" data-icon="bars"> 開啟面板</a>          </div>         <div data-role="panel" id="defaultpanel" data-theme="b">             <div class="panel-content">                 <h3> 面板</h3>                 <p> 這裡是內容地區</p>                 <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true"> 關閉面板 </a>              </div>                     </div>    </div> </body> 

加上CSS樣式:

    <style>            html,            body {                padding: 0;                margin: 0;            }                        html,            .ui-mobile,            .ui-mobile body {                height: 435px;            }                        .ui-mobile,            .ui-mobile .ui-page {                min-height: 435px;            }                        .ui-content {                padding: 10px 15px 0px 15px;            }                        .panel-content {                padding: 15px;                height: 500px;            }                        #header a {                margin-top: 3px;            }        </style>

這時候點開是這個樣子的:

然後我們開啟調試,進入到響應式布局(我這裡選用的iPhone6s螢幕尺寸):

這裡說明已經建立好一個面板了。

 

三、設定觸屏滑動事件(位置無限制)

<script type="text/javascript">    $("#page").on("swiperight", function() {        //我這裡的#page是使用最大那個面板的id        //向右滑動,顯示面板        $("#defaultpanel").panel("open");      //這裡的#defaultpanel_right改成自己定義的面板的id
}); </script>

 

 

 這樣子,滑鼠往右拉動就會彈出面板我們就完成了。

 

jQuery mobile 滑動開啟面板

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.