framework7教程

Framework7 标签

说明

标签是一组按逻辑分组的内容,允许我们在它们之间快速切换并像手风琴一样节省空间。

标签布局

以下代码定义了选项卡的布局-
<!--Tabs wrapper, shoud have "tabs" class.It is a required element-->
<div class = "tabs">
   <!--The tab, should have "tab" class and unique id attribute-->
   
   <!--The tab is active by default -"active" class -->
   <div class = "tab active" id = "tab1">
      ...  The content for Tab 1 goes here ...
   </div>
   
   <!--The second tab, should have "tab" class and unique id attribute-->
   <div class = "tab" id = "tab2">
      ... The content for Tab 2 goes here ...
   </div>
</div>
哪里-
-它是所有选项卡的必需包装器。如果我们错过了这一点,标签将根本无法使用。 -它是一个标签,它应该具有 唯一的 id 属性。 -它是一个单独的活动选项卡,它使用附加的 active 类使选项卡可见(活动)。

在标签之间切换

您可以在选项卡布局中使用一些控制器,以便用户可以在它们之间切换。
为此,您需要使用 tab-link 类和与 id 相同的 href 属性创建链接( 标签)目标标签的属性-
<!--Here the link is used to activates 1st tab, has the same href attribute (#tab1) as the id attribute of 1st tab (tab1) -->
<a href = "#tab1" class = "tab-link active">Tab 1</a>
<!--Here the link is used to activates 2st tab, has the same href attribute (#tab2) as the id attribute of 2st tab (tab2) -->
<a href = "#tab2" class = "tab-link">Tab 2</a>
<a href = "#tab3" class = "tab-link">Tab 3</a>

切换多个标签

如果您使用单个选项卡链接在多个选项卡之间切换,那么您可以使用类而不是使用 ID 的data-tab 属性。
<!--for Top Tabs -->
<div class = "tabs tabs-top">
   <div class = "tab tab1 active">...</div>
   <div class = "tab tab2">...</div>
   <div class = "tab tab3">...</div>
</div>
<!--for Bottom Tabs-->
<div class = "tabs tabs-bottom">
   <div class = "tab tab1 active">...</div>
   <div class = "tab tab2">...</div>
   <div class = "tab tab3">...</div>
</div>
<!--for Tabs links-->
<div class = "tab-links">
   <!--Links are switch top and bottom tabs to .tab1-->
   <a href = "#" class = "tab-link" data-tab = ".tab1">Tab 1</a>
   <!--Links are switch top and bottom tabs to .tab2-->
   <a href = "#" class = "tab-link" data-tab = ".tab2">Tab 2</a>
   <!--Links are switch top and bottom tabs to .tab3-->
   <a href = "#" class = "tab-link" data-tab = ".tab3">Tab 3</a>
</div>
tab-link 的 data-tab 属性包含目标标签/标签的 CSS 选择器。
我们可以使用不同的选项卡方式,这些在下表中指定-
S.No 标签类型和描述
1 内联标签
内联标签是内联分组的集合,允许您在它们之间快速切换。
2 从导航栏中切换标签
我们可以在导航栏中放置标签,让您可以在它们之间切换。
3 从标签栏切换视图
单个标签可用于在具有自己导航和布局的视图之间切换。
4 动画标签
您可以使用简单的过渡(动画)来切换标签。
5 可滑动标签
您可以使用 tabs-swipeable-wrap 类创建具有简单过渡的可滑动标签标签。
6 标签 JavaScript 事件
当您使用标签的 JavaScript 代码时,可以使用 JavaScript 事件。
7 使用 JavaScript 显示标签
您可以使用 JavaScript 方法切换或显示标签。
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4