jQuery Mobile彈出窗、彈出層知識匯總_jquery

來源:互聯網
上載者:User

先建立一個表單

<div data-role="popup" id="popupView" class="ui-content" data-overlay-theme="b" data-position-to="window" data-dismissible="false">  <a href='javascript:void(0)' data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>  <div>彈出窗內容<div></div>

1)點擊後彈出

<a href="#popupView" data-rel="popup" data-transition="flip" class="ui-btn ui-corner-all">按鈕</a> 

2)頁面載入後彈出

//頁面延時載入<script>setTimeout(function () {  $("#popupView").popup('open');}, 1000);//1秒</script> 

關鍵字說明:

data-overlay-theme: 背景色透明灰 data-position-to: 彈窗在視窗置中顯示 data-dismissible: 是否允許單擊視窗外任一位置關閉視窗(預設true為允許) data-transition: 彈出方式

下面通過代碼執行個體詳解jquery mobile 彈出層使用

引入檔案

<head> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"> <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> </head>

彈出層基礎

建立一個彈出層,要在div標籤中添加一個 data-role="popup" 屬性,然後在添加一個a標籤,並在a標籤href屬性中設定彈出div層的id,在a標籤中添加屬性

data-rel="popup"To create a popup, add the data-role="popup" attribute to a div with the popup contents. Then create a link with the href set to the id of the popup div, and add the attribute data-rel="popup" to tell the framework to open the popup when the link is tapped. A popup div has to be nested inside the same page as the link.<a href="#popupBasic" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline" data-transition="pop">Basic Popup</a><div data-role="popup" id="popupBasic"><p>This is a completely basic popup, no options set.</p></div>

簡單一實例

<!DOCTYPE html><html><head><link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"><script src="http://code.jquery.com/jquery-1.8.3.min.js"></script><script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script></head><body><div data-role="page" id="pageone"><a href="#popupBasic" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline" data-transition="pop">點擊我彈出層</a><div data-role="popup" id="popupBasic"><p>彈出層測試</p></div></div> </body></html>

工具提示可以通過添加一個主題建立樣本基本通過ui-content彈出並添加填充

A tooltip can be created by adding a theme swatch to a basic popup and adding padding via the ui-content class. <p>A paragraph with a tooltip. <a href="#popupInfo" data-rel="popup" data-transition="pop" class="my-tooltip-btn ui-btn ui-alt-icon ui-nodisc-icon ui-btn-inline ui-icon-info ui-btn-icon-notext" title="Learn more">Learn more</a></p><div data-role="popup" id="popupInfo" class="ui-content" data-theme="a" style="max-width:350px;"><p>Here is a <strong>tiny popup</strong> being used like a tooltip. The text will wrap to multiple lines as needed.</p></div>

提示資訊執行個體

<!DOCTYPE html><html><head><link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"><script src="http://code.jquery.com/jquery-1.8.3.min.js"></script><script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script></head><body><div data-role="page" id="pageone"><p>A paragraph with a tooltip. <a href="#popupInfo" data-rel="popup" data-transition="pop" class="my-tooltip-btn ui-btn ui-alt-icon ui-nodisc-icon ui-btn-inline ui-icon-info ui-btn-icon-notext" title="Learn more">Learn more</a></p><div data-role="popup" id="popupInfo" class="ui-content" data-theme="a" style="max-width:350px;"><p>Here is a <strong>tiny popup</strong> being used like a tooltip. The text will wrap to multiple lines as needed.</p></div></div> </body></html>

彈出圖片

<!DOCTYPE html><html><head><link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"><script src="http://code.jquery.com/jquery-1.8.3.min.js"></script><script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script></head><body><div data-role="page" id="pageone"><a href="#popupParis" data-rel="popup" data-position-to="window" data-transition="fade"><img class="popphoto" src="yun_qi_img/paris.jpg" alt="Paris, France" style="width:30%"></a><a href="#popupSydney" data-rel="popup" data-position-to="window" data-transition="fade"><img class="popphoto" src="yun_qi_img/sydney.jpg" alt="Sydney, Australia" style="width:30%"></a><a href="#popupNYC" data-rel="popup" data-position-to="window" data-transition="fade"><img class="popphoto" src="yun_qi_img/newyork.jpg" alt="New York, USA" style="width:30%"></a><div data-role="popup" id="popupParis" data-overlay-theme="b" data-theme="b" data-corners="false"><a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a><img class="popphoto" src="yun_qi_img/paris.jpg" style="max-height:512px;" alt="Paris, France"></div><div data-role="popup" id="popupSydney" data-overlay-theme="b" data-theme="b" data-corners="false"><a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a><img class="popphoto" src="yun_qi_img/sydney.jpg" style="max-height:512px;" alt="Sydney, Australia"></div><div data-role="popup" id="popupNYC" data-overlay-theme="b" data-theme="b" data-corners="false"><a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a><img class="popphoto" src="yun_qi_img/newyork.jpg" style="max-height:512px;" alt="New York, USA"></div></div> </body></html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.