gpt4 book ai didi

jquery - 右侧 Accordion 的响应式垂直标签

转载 作者:太空宇宙 更新时间:2023-11-03 23:31:02 28 4
gpt4 key购买 nike

我正在尝试使用响应式设计在右侧制作垂直标签。我试着搜索如何制作它,到目前为止我得到了我想要的东西,比如 http://codepen.io/anon/pen/kJGBL?editors=010

HTML

<ul class="tabs">
<li class="active" rel="tab1">Tab 1</li>
<li rel="tab2">Tab 2</li>
<li rel="tab3">Tab 3</li>
<li rel="tab4">Tab 4</li>

</ul>
<div class="tab_container">
<h3 class="d_active tab_drawer_heading" rel="tab1">Tab 1</h3>
<div id="tab1" class="tab_content">
<h2>Tab 1 content</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac metus augue.</p>
</div>
<!-- #tab1 -->
<h3 class="tab_drawer_heading" rel="tab2">Tab 2</h3>
<div id="tab2" class="tab_content">
<h2>Tab 2 content</h2>
<p>Nunc dui velit, scelerisque eu placerat volutpat, dapibus eu nisi. Vivamus eleifend vestibulum odio non vulputate.</p>
</div>
<!-- #tab2 -->
<h3 class="tab_drawer_heading" rel="tab3">Tab 3</h3>
<div id="tab3" class="tab_content">
<h2>Tab 3 content</h2>
<p>Nulla eleifend felis vitae velit tristique imperdiet. Etiam nec imperdiet elit. Pellentesque sem lorem, scelerisque sed facilisis sed, vestibulum sit amet eros.</p>
</div>
<!-- #tab3 -->
<h3 class="tab_drawer_heading" rel="tab4">Tab 4</h3>
<div id="tab4" class="tab_content">
<h2>Tab 4 content</h2>
<p>Integer ultrices lacus sit amet lorem viverra consequat. Vivamus lacinia interdum sapien non faucibus. Maecenas bibendum, lectus at ultrices viverra, elit magna egestas magna, a adipiscing mauris justo nec eros.</p>
</div>
<!-- #tab4 -->
</div>
<!-- .tab_container -->
</div>

CSS

ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
height: 32px;
border-bottom: 1px solid #333;
width: 100%;
}

ul.tabs li {
float: right;
display: block;
margin: 0;
cursor: pointer;
padding: 0px 21px;
height: 31px;
line-height: 31px;
border-top: 1px solid #333;
border-left: 1px solid #333;
border-bottom: 1px solid #333;
background-color: #666;
color: #ccc;
overflow: hidden;
position: relative;
}

.tab_last { border-right: 1px solid #333; }

ul.tabs li:hover {
background-color: #ccc;
color: #333;
}

ul.tabs li.active {
background-color: #fff;
color: #333;
border-bottom: 1px solid #fff;
display: block;
}

.tab_container {
border: 1px solid #333;
border-top: none;
clear: both;
float: left;
width: 100%;
background: #fff;
overflow: auto;
}

.tab_content {
padding: 20px;
display: none;
}

.tab_drawer_heading { display: none; }

@media screen and (max-width: 480px) {
.tabs {
display: none;
}
.tab_drawer_heading {
background-color: #ccc;
color: #fff;
border-top: 1px solid #333;
margin: 0;
padding: 5px 20px;
display: block;
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.d_active {
background-color: #666;
color: #fff;
}
}

但问题是选项卡是水平的。我希望我的选项卡是垂直的并且位于容器的右侧。

提前致谢。

最佳答案

在您的 HTML 中尝试以下 CSS:

ul.tabs {  
margin: 0;
padding: 0;
float: right;
list-style: none;
height: 32px;
width: 20%;
}

ul.tabs li {
display: block;
margin: 0;
cursor: pointer;
padding: 0px 21px;
height: 31px;
line-height: 31px;
border: 1px solid #333;
background-color: #666;
color: #ccc;
overflow: hidden;
position: relative;
}

.tab_last { border-right: 1px solid #333; }

ul.tabs li:hover {
background-color: #ccc;
color: #333;
}

ul.tabs li.active {
background-color: #fff;
color: #333;
display: block;
}

.tab_container {
border: 1px solid #333;
float: left;
width: 79%;
background: #fff;
}

.tab_content {
padding: 20px;
display: none;
}

.tab_drawer_heading { display: none; }

@media screen and (max-width: 480px) {

.tab_container {
width: 100%;
}

.tabs {
display: none;
}
.tab_drawer_heading {
background-color: #ccc;
color: #fff;
border-top: 1px solid #333;
margin: 0;
padding: 5px 20px;
display: block;
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.d_active {
background-color: #666;
color: #fff;
}
}

关于jquery - 右侧 Accordion 的响应式垂直标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25323531/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com