jQuery Mobile Collapsible

可折疊的內容塊

可折疊(Collapsibles)允許您隱藏或顯示內容 - 對於存儲部分信息很有用。

如需創建可折疊的內容塊,請向某個容器分配 data-role="collapsible" 屬性。在容器(div)中,添加一個標題元素(h1-h6),其後是您需要展開的任意 HTML 標記:

實例

<div data-role="collapsible">
  <h1>點擊我 - 我可以折疊!</h1>
  <p>我是可折疊的內容。</p>
</div>

亲自試試

默認地,該內容是關閉的。如需在頁面加載時展開內容,請使用 data-collapsed="false":

實例

<div data-role="collapsible" data-collapsed="false">
  <h1>點擊我 - 我可以折疊!</h1>
  <p>現在我默認是展開的。</p>
</div>

亲自試試

嵌套的可折疊塊

可以嵌套可折疊內容塊:

實例

<div data-role="collapsible">
  <h1>點擊我 - 我可以折疊!</h1>
  <p>我是被展開的內容。</p>
  <div data-role="collapsible">
    <h1>點擊我 - 我是嵌套的可折疊塊!</h1>
    <p>我是嵌套的可折疊塊中被展開的內容。</p>
  </div>
</div>

亲自試試

提示:可折疊內容塊可以被嵌套您希望的任意次數。

可折疊集合

可折疊集合(Collapsible sets)指的是被組合在一起的可折疊塊(常被稱為手風琴)。當新塊被打開時,所有其他塊會關閉。

創建若干內容塊,然後通過 data-role="collapsible-set" 用新容器包裝這個可折疊塊:

實例

<div data-role="collapsible-set">
  <div data-role="collapsible">
    <h1>點擊我 - 我可以折疊!</h1>
    <p>我是被展開的內容。</p>
  </div>
  <div data-role="collapsible">
    <h1>點擊我 - 我可以折疊!</h1>
    <p>我是被展開的內容。</p>
  </div>
</div>

亲自試試

Maraming halimbawa

Alisin ang mga rounded corners sa pamamagitan ng data-inset attribute
Paano alisin ang mga rounded corners sa collapsibles.
Iminimize ang collapsibles sa pamamagitan ng data-mini
Paano gawing mas maliit ang collapsibles.
Ibang icon sa pamamagitan ng data-collapsed-icon at data-expanded-icon
Paano baguhin ang mga icon ng collapsibles (ang default ay + at -).