jQuery Mobile 主題
jQuery Mobile 主題
jQuery Mobile 提供了五種不同的樣式主題,從 "a" 到 "e" - 每種主題帶有不同顏色的按鈕、欄、內容塊,等等。jQuery Mobile 中的一種主題由多種可見的效果和顏色構成。
如需定制應用程序的外觀,請使用 data-theme 屬性,并為該屬性分配一個字母:
<div data-role="page" data-theme="a|b|c|d|e"
>
值 | 描述 | 例子 |
---|---|---|
a | 默認。黑色背景上的白色文本。 | 測試 |
b | 藍色背景上的白色文本 / 灰色背景上的黑色文本 | 測試 |
c | 亮灰色背景上的黑色文本 | 測試 |
d | 白色背景上的黑色文本 | 測試 |
e | 橙色背景上的黑色文本 | 測試 |
提示:混合您喜歡的主題!
默認地,jQuery Mobile 為頁眉和頁腳使用 "a" 主題,為頁眉內容使用 "c" 主題(亮灰)。不過,您能夠自如地對主題進行混合。
主題化的頁面、內容和頁腳
實例
<div data-role="header" data-theme="b"></div> <div data-role="content" data-theme="a"></div> <div data-role="footer" data-theme="e"></div>
主題化的對話框
實例
<a href="#pagetwo" data-rel="dialog">Go To The Themed Dialog Page</a> <div data-role="page" id="pagetwo" data-overlay-theme="e"> <div data-role="header" data-theme="b"></div> <div data-role="content" data-theme="a"></div> <div data-role="footer" data-theme="c"></div> </div>
主題化的按鈕
實例
<a href="#" data-role="button" data-theme="a">Button</a> <a href="#" data-role="button" data-theme="b">Button</a> <a href="#" data-role="button" data-theme="c">Button</a>
頁眉和頁腳中的主題化按鈕
實例
<div data-role="header"> <a href="#" data-role="button" data-icon="home" data-theme="b">Home</a> <h1>Welcome To My Homepage</h1> <a href="#" data-role="button" data-icon="search" data-theme="e">Search</a> </div> <div data-role="footer"> <a href="#" data-role="button" data-theme="b" data-icon="plus">Button 1</a> <a href="#" data-role="button" data-theme="c" data-icon="plus">Button 2</a> <a href="#" data-role="button" data-theme="e" data-icon="plus">Button 3</a> </div>
主題化的導航欄
實例
<div data-role="footer" data-theme="e"> <h1>Insert Footer Text Here</h1> <div data-role="navbar"> <ul> <li><a href="#" data-icon="home" data-theme="b">Button 1</a></li> <li><a href="#" data-icon="arrow-r">Button 2</a></li> <li><a href="#" data-icon="arrow-r">Button 3</a></li> <li><a href="#" data-icon="search" data-theme="a" >Button 4</a></li> </ul> </div> </div>
主題化的可折疊按鈕和內容
實例
<div data-role="collapsible" data-theme="b" data-content-theme="e"> <h1>Click me - I'm collapsible!</h1> <p>I'm the expanded content.</p> </div>
主題化列表
實例
<ul data-role="listview" data-theme="e"> <li><a href="#">List Item</a></li> <li data-theme="a"><a href="#">List Item</a></li> <li data-theme="b"><a href="#">List Item</a></li> <li><a href="#">List Item</a></li> </ul>
主題化的可折疊列表
實例
<div data-role="collapsible" data-theme="b" data-content-theme="e"> <ul data-role="listview"> <li><a href="#">Agnes</a></li> </ul> </div>
主題化表單
實例
<label for="name">Full Name:</label> <input type="text" name="text" id="name" data-theme="a"> <label for="colors">Choose Favorite Color:</label> <select id="colors" name="colors" data-theme="b"> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option> </select>
主題化的可折疊表單
實例
<fieldset data-role="collapsible" data-theme="b" data-content-theme="e"> <legend>Click me - I'm collapsible!</legend>
添加新主題
jQuery Mobile 同時允許您向移動頁面添加新主題。
請通過編輯 CSS 文件(如已下載 jQuery Mobile)來添加或編輯新主題。只需拷貝一段樣式,并用字母名(f-z)來對類進行重命名,然后調整為您喜歡的顏色和字體即可。
您也可以通過在 HTML 文檔中使用主題類來添加新樣式 - 為工具條添加類 ui-bar-(a-z),并為內容添加類 ui-body-(a-z):
實例
<style> .ui-bar-f { color:green; background-color:yellow; } .ui-body-f { font-weight:bold; color:purple; } </style>