jQuery Mobile 按鈕、圖標

jQuery Mobile 中創建按鈕
可通過三種方法創建:
1.使用<button> 元素
2.使用<input>元素
3.使用 data-role=”button” 的<a> 元素

★推薦使用 data-role=”button” 的 <a> 元素來創建頁面之間的鏈接,而<input><button>元素用於表單提交。

按鈕的基本屬性
1.默認情況下,按鈕會佔據屏幕的全部寬度。若需要按鈕適應其內容,或者需要兩個或多個按鈕並排顯示時,添加
data-inline="true"
eg:

<a href="#" data-inline="true" data-role="button">a標籤 按鈕</a>
<a href="#" data-inline="true" data-role="button">a標籤 按鈕</a>
<a href="#" data-inline="true" data-role="button">a標籤 按鈕</a>

這裏寫圖片描述
2.規定按鈕是否有陰影

data-shadow="false|true"

規定是否有圓角

data-corners="false|true"

3.按鈕的主題顏色
data-theme="letter(a-z)"
eg:
<div data-role="header" data-theme="b">
<h1>第 1 頁</h1>
</div>

4.創建後腿按鈕,使用data-rel="back"屬性,該屬性會忽略錨的href值。如下例,雖然寫的鏈接到百度,但實際上點按鈕時,則是返回上一頁。
eg:

<a href="http://www.baidu.com" data-rel="back" data-role="button">返回

5.將 data-role=”controlgroup” 屬性與 data-type=”horizontal|vertical” 一同使用

<div data-role="controlgroup" data-type="horizontal">
3     <a href="#" data-role="button" data-theme="a">首頁</a>
4     <a href="#" data-role="button" data-theme="b">介紹</a>
5     <a href="#" data-role="button" data-theme="c">聯繫</a>
6 </div>

這裏寫圖片描述

jQuery Mobile 中創建圖標
1.常見的可用圖標:data-icon屬性
這裏寫圖片描述

<a href="#" data-inline="true" data-role="button" data-icon="arrow-u"></a>
<a href="#" data-inline="true" data-role="button" data-icon="arrow-d"></a>
<a href="#" data-inline="true" data-role="button" data-icon="arrow-l"></a>
<a href="#" data-inline="true" data-role="button" data-icon="arrow-r"></a>

這裏寫圖片描述

2.定位圖標: 請使用 data-iconpos 屬性來規定位置
eg:

<a href="#" data-inline="true" data-role="button" data-icon="arrow-u" data-iconpos="top"></a>
 <a href="#" data-inline="true" data-role="button" data-icon="arrow-d" data-iconpos="bottom"></a>
 <a href="#" data-inline="true" data-role="button" data-icon="arrow-l" data-iconpos="left"></a>
 <a href="#" data-inline="true" data-role="button" data-icon="arrow-r" data-iconpos="right"></a>

這裏寫圖片描述
3.如果只需顯示圖標,請將 data-iconpos 設置爲 “notext”

<a href="#" data-inline="true" data-role="button" data-icon="search" data-iconpos="notext">搜索</a>
<a href="#" data-inline="true" data-role="button" data-icon="home" data-iconpos="notext">主頁</a>
<a href="#" data-inline="true" data-role="button" data-icon="info" data-iconpos="notext">消息</a>

這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章