JS实现侧边选项卡功能

**一、简述:**通过JS实现简单的选项卡功能,本示例是左右布局,要实现上下布局只需更改样式即可。**二、功能介绍:**页面初始第一个选项——此示例为“第一天”为选中状态,对应右侧的内容——“学习HTML基础”,当鼠标点击第二个选项——此处为“第二天”,右侧出现对应内容——“学习CSS基础”……以此类推,实现点击左侧选项右侧出现相应内容。**功能实现图**(后边依次类推)页面内容编写——HTML<!DOCTYPE html><html> <head>
摘要由CSDN通过智能技术生成

**一、简述:**通过JS实现简单的选项卡功能,本示例是左右布局,要实现上下布局只需更改样式即可。
**二、功能介绍:**页面初始第一个选项——此示例为“第一天”为选中状态,对应右侧的内容——“学习HTML基础”,当鼠标点击第二个选项——此处为“第二天”,右侧出现对应内容——“学习CSS基础”……以此类推,实现点击左侧选项右侧出现相应内容。
**

功能实现图

**
第一个选项对应右侧内容显示
点击第二个选项右侧对应内容改变
点击第三个选项右侧内容对应改变
(后边依次类推)

页面内容编写——HTML

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>选项卡</title>
		<link rel="stylesheet" href="index.css">
	</head>
	<body>
		<div class="container">
			<div class="header">
				<div class="top">
					<div class="wpp">
						<div class="z">
							<span>选项卡功能实现</span>
						</div>
						
					</div>
				</div>
			</div>
			<div class="center">
				<div class="wp">
				<div class="tab_contents">
					<ul class
  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Bootstrap提供了一种实现侧边选项卡的方法,可以在左侧或右侧显示竖直的选项卡。您可以使用Bootstrap的CSS类和组件来实现这个效果。通过添加适当的类和结构,您可以创建一个侧边选项卡布局。 要实现左侧或右侧的竖直选项卡,您可以使用Bootstrap的Tabs组件,并添加适当的CSS类。您可以使用"flex-column"类将选项卡设置为竖直排列,并使用"nav"类将选项卡标记为导航。 下面是一个示例代码,演示如何使用Bootstrap实现侧边选项卡布局: ```html <div class="container"> <div class="row"> <div class="col-3"> <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical"> <a class="nav-link active" id="v-pills-home-tab" data-bs-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a> <a class="nav-link" id="v-pills-profile-tab" data-bs-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a> <a class="nav-link" id="v-pills-messages-tab" data-bs-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a> </div> </div> <div class="col-9"> <div class="tab-content" id="v-pills-tabContent"> <div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab"> <h4>Home tab content</h4> <p>This is the content of the home tab.</p> </div> <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab"> <h4>Profile tab content</h4> <p>This is the content of the profile tab.</p> </div> <div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab"> <h4>Messages tab content</h4> <p>This is the content of the messages tab.</p> </div> </div> </div> </div> </div> ``` 在这个示例中,我们使用了"flex-column"类将选项卡设置为竖直排列。每个选项卡都包含一个链接元素,使用"data-bs-toggle"和"href"属性来切换选项卡内容。选项卡内容是用"tab-content"类包裹的,并使用相应的ID和角色来关联选项卡和内容。 希望这个示例对您有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [BootStrap实现左侧或右侧竖式tab选项卡](https://blog.csdn.net/w1366352655/article/details/86156263)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Bootstrap5 组件](https://blog.csdn.net/qq_44174346/article/details/126056554)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值