jQuery Mobile - 样式和主题对话框
描述
可以将不同的样式和主题应用于对话框。 以下是将主题和样式应用于对话框的方法 −
通过将属性 data-theme 添加到任何容器(例如页眉、页脚或内容),可以将主题包含在对话框中。
包括 data-corners = "false" 以删除对话框的圆角,因为默认情况下角设置为圆角。
data-overlay-theme 属性将覆盖设置为任何模式字母。
也可以在对话框中使用多个按钮。 通过将 {margin-top:0} 包含到为页面指定的类中,可以将对话框固定在顶部。 ui-dialog.my-dialog .ui-dialog-contain
示例
以下示例演示了在 jQuery Mobile 中使用样式和主题对话框。
<!DOCTYPE html> <html> <head> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script> <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> <style> .ui-dialog.dialog-actionsheet .ui-dialog-contain { margin-top: 0; } </style> </head> <body> <div data-role = "page" id = "page1"> <div data-role = "header" data-theme = "b"> <h2>Header</h2> </div> <div role = "main" class = "ui-content"> <a href = "#page2" class = "ui-btn ui-corner-all ui-btn-inline"> Open Dialog</a> <a href = "#page3" class = "ui-btn ui-corner-all ui-btn-inline"> Photos Dialog</a> </div> <div data-role = "footer"> <h4>Footer</h4> </div> </div> <div data-role = "page" data-dialog = "true" id = "page2" data-corners = "false" data-overlay-theme = "b"> <div data-role = "header"> <h1>First Dialogs</h1> </div> <div role = "main" class = "ui-content"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p> <a data-rel = "back" class = "ui-btn ui-corner-all ui-btn-inline">Back</a> </div> </div> <div data-role = "page" class = "dialog-actionsheet" data-dialog = "true" id = "page3"> <div role = "main" class = "ui-content"> <h3>Share Photos</h3> <a href = "#page4" data-transition = "slidedown" class = "ui-btn ui-shadow ui-corner-all ui-btn-b">Email</a> <a href = "#page4" data-transition = "slidedown" class = "ui-btn ui-shadow ui-corner-all ui-btn-b">Share on Facebook</a> <a href = "#page4" data-transition = "slidedown" class = "ui-btn ui-shadow ui-corner-all ui-btn-b">Tweet photo</a> <a data-rel = "back" class = "ui-btn ui-shadow ui-corner-all ui-btn-a"> Cancel</a> </div> </div> <div data-role = "page" class = "dialog-actionsheet" data-dialog = "true" id = "page4"> <div role = "main" class = "ui-content"> <h3>Photos uploaded successfully</h3> <a href = "#page1" class = "ui-btn ui-shadow ui-corner-all ui-btn-a"> View photo page</a> <a href = "#page1" class = "ui-btn ui-shadow ui-corner-all ui-btn-a"> Done</a> </div> </div> </body> </html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 style_theming.html 文件。
将此 HTML 文件打开为 http://localhost/style_theming.html,将显示以下输出。