標籤: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 滑動開啟面板