前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Bootstrap响应式前端框架笔记十九——标签页的使用

Bootstrap响应式前端框架笔记十九——标签页的使用

作者头像
珲少
发布2018-08-15 14:58:05
7770
发布2018-08-15 14:58:05
举报
文章被收录于专栏:一“技”之长一“技”之长

Bootstrap响应式前端框架笔记十九——标签页的使用

    Bootstrap中通过为导航标签增加data-toggle="tab",配合类或id来进行标签页的关联,示例如下:

代码语言:javascript
复制
		<ul class="nav nav-tabs">
			<li class="active">
				<a href="#one" data-toggle="tab" id="aone">第一页</a>
			</li>
			<li>
				<a href="#two" data-toggle="tab" id="atwo">第二页</a>
			</li>
			<li>
				<a href="#three" data-toggle="tab" id="athree">第三页</a>
			</li>
			<li>
				<a href="#four" data-toggle="tab" id="afour">第四页</a>
			</li>
		</ul>

		<!-- Tab panes -->
		<div class="tab-content">
			<div class="tab-pane active fade in" id="one">On iPhone 7 and iPhone 7 Plus, haptics provide additional ways to physically engage users with tactile feedback that gets attention and reinforces actions. Some system-provided interface elements, such as pickers, switches, and sliders, automatically provide haptic feedback as users interact with them</div>
			<div class="tab-pane" id="two">Using one of the concrete subclasses, you ask the system to generate haptics for a specific scenario and iOS manages the strength and behavior of the feedback based on the scenario you choose. In addition, you can call the prepare method of UIFeedbackGenerator to inform the system that haptic feedback is about to be required and to minimize latency. To learn how to use haptics to provide the best user experience in your app, see “Haptic Feedback” in iOS Human Interface Guidelines.

</div>
			<div class="tab-pane" id="three">When the user makes a request involving your service, SiriKit sends your extension an intent object, which describes the user’s request and provides any data related to that request. You use the intent object to provide an appropriate response object, which includes details of how you can handle the user’s request. Siri typically handles all user interactions, but you can use an extension to provide custom UI that incorporates branding or additional information from your app.</div>
			<div class="tab-pane" id="four">To learn how to support SiriKit and give users new ways to access your services, read SiriKit Programming Guide. When you’re ready to implement the app extensions that handle various intents, see Intents Framework Reference and Intents UI Framework Reference.

</div>
		</div>

效果如图:

为tab-pane类增加fade in类可以使标签切换时带渐入动画。

    Bootstrap中的标签页JS组件提供了一个tab函数,使用这个方法可以实现代码控制标签的切换,示例如下:

代码语言:javascript
复制
        <button class="btn btn-primary" id="cone">第一页</button>
		<button class="btn btn-primary" id="ctwo">第二页</button>
		<button class="btn btn-primary" id="cthree">第三页</button>
		<button class="btn btn-primary" id="cfour">第四页</button>
		<script>
			$("#cone").on("click",function(){
				$("#aone").tab('show');
			});
			$("#ctwo").on("click",function(){
				$("#atwo").tab('show');
			});
			$("#cthree").on("click",function(){
				$("#athree").tab('show');
			});
			$("#cfour").on("click",function(){
				$("#afour").tab('show');
			});
		</script>

Bootstrap中还提供了一些监听事件,开发者可以向导航标签中添加这些监听事件来监听标签页的状态,示例如下:

代码语言:javascript
复制
			$("#aone").on("show.bs.tab",function(){
				console.log("此标签页将要显示");
			});
			$("#aone").on("shown.bs.tab",function(){
				console.log("此标签页已经显示");
			});
			$("#aone").on("hide.bs.tab",function(){
				console.log("此标签页将要隐藏");
			});
			$("#aone").on("hidden.bs.tab",function(){
				console.log("此标签页已经隐藏");
			});

   另外,本篇博客中所有的实例代码及显示效果,在如下地址中,需要的可以自行对照学习。

http://zyhshao.github.io/bootStrapDemo/PageJS.html

前端学习新人,有志同道合的朋友,欢迎交流与指导,QQ群:541458536

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017/01/02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Bootstrap响应式前端框架笔记十九——标签页的使用
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档