- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
当页面小于 480 像素时,我试图将我的垂直选项卡转换为 Accordion View ,如果不是,则返回垂直选项卡 View 。我尝试使用 @media screen 和 (min-width: 480px) {}
+ 添加垂直标签 CSS 样式,但我最终无处可去。然后我尝试搜索一种方法来在线执行此操作。我最终找到了一些例子,但他们使用了不同的方法来实现这种效果。当屏幕小于 480px 时,如何让这个垂直标签变成 Accordion ?
下面的链接是我想要的效果的示例。 (查看示例时调整窗口大小以查看垂直制表符/ Accordion 效果)
示例:https://codepen.io/thejettmiller/pen/hqnua
$(document).ready(function() {
//----------Select the first tab and div by default
$('#vertical_tab_nav > ul > li > a').eq(0).addClass("selected");
$('#vertical_tab_nav > div > article').eq(0).css('display', 'block');
//---------- This assigns an onclick event to each tab link("a" tag) and passes a parameter to the showHideTab() function
$('#vertical_tab_nav > ul').click(function(e) {
if ($(e.target).is("a")) {
/*Handle Tab Nav*/
$('#vertical_tab_nav > ul > li > a').removeClass("selected");
$(e.target).addClass("selected");
/*Handles Tab Content*/
var clicked_index = $("a", this).index(e.target);
$('#vertical_tab_nav > div > article').css('display', 'none');
$('#vertical_tab_nav > div > article').eq(clicked_index).fadeIn();
}
$(this).blur();
return false;
});
}); //end ready
/* if in drawer mode */
$(".tab_drawer_heading").click(function() {
$(".tab_content").hide();
var d_activeTab = $(this).attr("rel");
$("#"+d_activeTab).fadeIn();
$(".tab_drawer_heading").removeClass("d_active");
$(this).addClass("d_active");
$("ul.tabs li").removeClass("active");
$("ul.tabs li[rel^='"+d_activeTab+"']").addClass("active");
});
body {
margin: 0px;
padding: 20px;
background: #9adde5;
font-family: arial, sans-serif;
font-size: 10pt;
line-height: 15pt;
}
/*---------- vertical tab nav */
#vertical_tab_nav {
display: block;
width: 100%;
}
#vertical_tab_nav ul {
display: block;
float: left;
margin: 0px;
padding: 0px;
list-style: none;
overflow: hidden;
width: 30%;
border-radius: 10px 0 0 10px;
background: #555;
}
#vertical_tab_nav li {
border-bottom: 1px solid #000;
margin-bottom: 1px;
text-align: left;
padding: 0px;
}
#vertical_tab_nav li:last-child {
margin-bottom: 0px;
border-bottom: 0px;
}
#vertical_tab_nav li a {
display: block;
font-size: 14pt;
color: #fff;
text-decoration: none;
padding: 7%;
background: #57cac9;
background: -webkit-linear-gradient(top, #444, #333);
background: -moz-linear-gradient(top, #444, #333);
}
#vertical_tab_nav li a.selected {
background: #fff;
color: #000;
}
#vertical_tab_nav div {
display: block;
float: left;
background: #fff;
background: #fff;
width: 64%;
min-height: 500px;
padding: 10px 3% 3% 3%;
border-radius: 0 10px 10px 0;
}
#vertical_tab_nav div article {
display: none;
margin: 0px;
color: #555;
}
#vertical_tab_nav div article p {
margin: 0px 0px 20px 0px;
}
.tab_drawer_heading {
display: none;
}
@media screen and (max-width: 781px) {
ul.tabs {
display: none;
}
.tab_container {
display: block;
margin: 0 auto;
width: 95%;
border-top: none;
border-radius: 0;
box-shadow: 0px 0px 10px black;
}
.tab_drawer_heading {
background-color: #ccc;
color: #000;
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;
text-align: center;
&:hover {
background: #ccc;
}
}
.d_active {
background: #fff;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section id="vertical_tab_nav">
<ul class="tabs">
<li><a href="index.html">Tab One</a></li>
<li class="selected"><a href="index.html">Tab Two</a></li>
<li><a href="index.html">Tab Three</a></li>
<li><a href="index.html">Tab Four</a></li>
</ul>
<div class="tab_container">
<article>
<h2 class="d_active tab_drawer_heading">Tab Content One</h2>
<p>Adult education is essential for Democracy of India. The number of grown up illiterates is great. All college and senior School students should come forward to visit villages in the summer vacation. Each one will teach one there. This will remove
illiteracy and strengthen our democracy.</p>
<p>I happened to see a one day cricket match between Pakistan and Australia at Wankhade Stadium, Mumbai. I went for a fun. But I witnessed a horrible sight. Two thousand ticketless cricket fans gate crashed. There was a stampede. Three persons died
and twenty were injured. Administration was responsible for it.</p>
</article>
<article>
<h2 class="d_active tab_drawer_heading">Tab Content Two</h2>
<p>City Anti-pollution Drive demands certain steps from all the citizens of ABC city. All house-holders should pack the waste in a plastic bag and put the bag in front of their house. The bag will be replaced with an empty bag by the Municipal van
every morning. They should maintain the cleanliness of the city. This will make the city pollution free.</p>
<p>My visit to a slum area after the rainy season was a sad affair. The pits were still full of rain water. There was mud all around. The polluted water had caused various diseases. There was no home without a sick person. Small children suffered from
stomach troubles. The government should immediately rush to the help of the sufferers in the slum area.</p>
</article>
<article>
<h2 class="d_active tab_drawer_heading">Tab Content Three</h2>
<p>I saw a man climbing down a water pipe. He had a knife in his hand. I hit his hand with a brick. He fell down on the ground and I jumped upon him. Soon others reached there and we handed him over to the police.</p>
<p>A tragedy took place yesterday when a Matador fell into a canal. The driver of the Matador tried to save an auto-rickshaw and lost control on the vehicle. About fifty students were travelling in it. The people from the nearby villages saved twenty-seven
students. The dead bodies of the drowned were recovered. It was a very painful sight.</p>
</article>
<article>
<h2 class="d_active tab_drawer_heading">Tab Content Four</h2>
<p>City life is full of fun. There are parks and picnic spots to visit. We have cinema halls to see movies. We have electricity which runs our factories, light and cools our home and helps us in seeing T.V. There are all type of amenities like water,
health check up and transport. Sometimes circus shows and magic shows entertain the city people.</p>
<p>I was lucky to escape death by a few seconds.' A bomb blasted in the compartment of Nilanchal Express. The overcrowded compartment made me to get down. Anyhow the loss was great. About ten people died and many got injured. It was the job of a terrorist.
The government should intensify searching operations in trains.1</p>
</article>
</div>
</section>
最佳答案
我相信这就是您所追求的:
Codepen 链接:https://codepen.io/teodragovic/pen/wqEvOV
$(document).ready(function() {
//----------Select the first tab and div by default
$('#vertical_tab_nav > ul > li > a').eq(0).addClass("selected");
$('#vertical_tab_nav > div > article').eq(0).css('display', 'block');
//---------- This assigns an onclick event to each tab link("a" tag) and passes a parameter to the showHideTab() function
$('#vertical_tab_nav > ul').click(function(e) {
if ($(e.target).is("a")) {
/*Handle Tab Nav*/
$('#vertical_tab_nav > ul > li > a').removeClass("selected");
$(e.target).addClass("selected");
/*Handles Tab Content*/
var clicked_index = $("a", this).index(e.target);
$('#vertical_tab_nav > div > article').css('display', 'none');
$('#vertical_tab_nav > div > article').eq(clicked_index).fadeIn();
}
$(this).blur();
return false;
});
}); //end ready
/* if in drawer mode */
$(".tab_drawer_heading").click(function() {
$("article").hide();
var d_activeTab = $(this).attr("rel");
$("#"+d_activeTab).fadeIn();
$(".tab_drawer_heading").removeClass("d_active");
$(this).addClass("d_active");
$("ul.tabs li a").removeClass("selected");
$("ul.tabs li a[rel^='"+d_activeTab+"']").addClass("selected");
});
body {
margin: 0px;
padding: 20px;
background: #9adde5;
font-family: arial, sans-serif;
font-size: 10pt;
line-height: 15pt;
}
/*---------- vertical tab nav */
#vertical_tab_nav {
display: block;
width: 100%;
}
.tabs {
float: left;
margin: 0px;
padding: 0px;
list-style: none;
overflow: hidden;
width: 30%;
border-radius: 10px 0 0 10px;
background: #555;
}
.tabs li {
border-bottom: 1px solid #000;
margin-bottom: 1px;
text-align: left;
padding: 0px;
}
#vertical_tab_nav li:last-child {
margin-bottom: 0px;
border-bottom: 0px;
}
#vertical_tab_nav li a {
display: block;
font-size: 14pt;
color: #fff;
text-decoration: none;
padding: 7%;
background: #57cac9;
background: -webkit-linear-gradient(top, #444, #333);
background: -moz-linear-gradient(top, #444, #333);
}
#vertical_tab_nav li a.selected {
background: #fff;
color: #000;
}
.tab_container {
display: block;
background: #fff;
width: 80%;
min-height: 500px;
}
#vertical_tab_nav div article {
display: none;
margin: 0px;
color: #555;
padding: 10px 3% 3% 3%;
}
#vertical_tab_nav div article p {
margin: 0px 0px 20px 0px;
}
@media screen and (max-width: 781px) {
.tab_container {
display: block;
margin: 0 auto;
width: 95%;
border-top: none;
border-radius: 0;
box-shadow: 0px 0px 10px black;
}
.d_active {
background: #fff;
}
}
.tabs {
display: none;
}
// style accordion links
.tab_drawer_heading {
margin: 0;
font-size: 14pt;
color: #fff;
text-decoration: none;
padding: 3%;
background: #57cac9;
background: -webkit-linear-gradient(top, #444, #333);
background: -moz-linear-gradient(top, #444, #333);
}
@media screen and (min-width: 480px) {
.tab_container {
float: left;
padding: 10px 3% 3% 3%;
border-radius: 0 10px 10px 0;
width: 64%;
}
.tabs {
display: block;
}
.tab_drawer_heading {
display: none;
}
article {
padding: 0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<section id="vertical_tab_nav">
<ul class="tabs">
<li><a rel="tab1" href="index.html">Tab One</a></li>
<li><a rel="tab2" href="index.html">Tab Two</a></li>
<li><a rel="tab3" href="index.html">Tab Three</a></li>
<li><a rel="tab4" href="index.html">Tab Four</a></li>
</ul>
<div class="tab_container">
<h3 class="tab_drawer_heading" rel="tab1">Tab One</h3>
<article id="tab1">
<h2>Tab Content One</h2>
<p>Adult education is essential for Democracy of India. The number of grown up illiterates is great. All college and senior School students should come forward to visit villages in the summer vacation. Each one will teach one there. This will remove
illiteracy and strengthen our democracy.</p>
<p>I happened to see a one day cricket match between Pakistan and Australia at Wankhade Stadium, Mumbai. I went for a fun. But I witnessed a horrible sight. Two thousand ticketless cricket fans gate crashed. There was a stampede. Three persons died
and twenty were injured. Administration was responsible for it.</p>
</article>
<h3 class="tab_drawer_heading" rel="tab2">Tab Two</h3>
<article id="tab2">
<h2>Tab Content Two</h2>
<p>City Anti-pollution Drive demands certain steps from all the citizens of ABC city. All house-holders should pack the waste in a plastic bag and put the bag in front of their house. The bag will be replaced with an empty bag by the Municipal van
every morning. They should maintain the cleanliness of the city. This will make the city pollution free.</p>
<p>My visit to a slum area after the rainy season was a sad affair. The pits were still full of rain water. There was mud all around. The polluted water had caused various diseases. There was no home without a sick person. Small children suffered from
stomach troubles. The government should immediately rush to the help of the sufferers in the slum area.</p>
</article>
<h3 class="tab_drawer_heading" rel="tab3">Tab Three</h3>
<article id="tab3">
<h2>Tab Content Three</h2>
<p>I saw a man climbing down a water pipe. He had a knife in his hand. I hit his hand with a brick. He fell down on the ground and I jumped upon him. Soon others reached there and we handed him over to the police.</p>
<p>A tragedy took place yesterday when a Matador fell into a canal. The driver of the Matador tried to save an auto-rickshaw and lost control on the vehicle. About fifty students were travelling in it. The people from the nearby villages saved twenty-seven
students. The dead bodies of the drowned were recovered. It was a very painful sight.</p>
</article>
<h3 class="tab_drawer_heading" rel="tab4">Tab Four</h3>
<article id="tab4">
<h2>Tab Content Four</h2>
<p>City life is full of fun. There are parks and picnic spots to visit. We have cinema halls to see movies. We have electricity which runs our factories, light and cools our home and helps us in seeing T.V. There are all type of amenities like water,
health check up and transport. Sometimes circus shows and magic shows entertain the city people.</p>
<p>I was lucky to escape death by a few seconds.' A bomb blasted in the compartment of Nilanchal Express. The overcrowded compartment made me to get down. Anyhow the loss was great. About ten people died and many got injured. It was the job of a terrorist.
The government should intensify searching operations in trains.1</p>
</article>
</div>
</section>
您的代码中遗漏/错误的地方:
<h3>
用作 Accordion 链接的标签(如果您希望它们也是内容的标题,则在宽度小于 480 像素时隐藏文章标题)并应用 .tab_drawer_heading
到该元素而不是文章标题元素。rel
属性和 id
在使“抽屉”JS 代码工作的文章上.selected
选项卡导航链接上的类而不是 .active
在 parent 身上 <li>
.关于javascript - 将垂直制表符转换为 Accordion ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45828633/
我有两个可以相互交换数据的列表。我的列表之一是 Accordion 列表,您可以在其中放置数据,但也包含更多特定的 Accordion ,这些 Accordion 也允许在其中放置数据。我可以在表之间
我正在从数据库中获取记录,我必须在 Accordion 中显示这些记录。我能够显示记录。现在我正在做的是,我必须显示第一个打开的 Accordion ,然后在单击然后关闭上一个打开的 Accordio
我有一个 Accordion ,我希望具有以下功能:当用户单击链接展开时,其他展开的链接(如果有)将折叠。我知道这个功能是内置在 Accordion 插件中的,但我试图避免添加另一个库(jQuery
有点奇怪,这个。我有两个 jquery Accordion 实体,在点击一个 Accordion 中的一个项目时,我想将它动态添加到第二个 Accordion 中,并将其隐藏在原件中。 目前从 A 移
我尝试了以下代码,除了 FontAwesome 图标之外,一切都很好。我尝试在 Google 上寻找解决方案,但找不到我正在寻找的解决方案。 当我单击其中一个 Accordion 时,另一个 Acco
我正在使用 Bootstrap 制作一个响应式网站,它包含带有大量文本的嵌套 Accordion ,当您读到底部并单击下一个 Accordion 时,大量文本被折叠,我留在了页面底部。 我从 Boot
尝试创建嵌套 Accordion 时,是否可以使用 jquery 在另一个 Accordion 内部创建 anchor 链接和 Accordion ? 例如,在我的代码中我有 用于 Accordion
我正在实现一个嵌套 Accordion ,但是当我点击父级 Accordion 中的子组件时,它关闭了父级。我希望它在点击 child 时保持打开状态。 HTML: Home
我试图在 bootstrap Accordion 中添加加号和减号,当显示内容的 div 打开时显示加号,关闭时显示减号,当我打开第二个选项卡时它应该关闭其他打开的选项卡的内容(这个当前正在发生)并且
我有 Angular 5 应用程序,我正在使用 PrimeNG 组件。我创建了带有定义标题的 PrimeNG Accordion ,其中有标题和一些操作按钮,如下所示:
我有一个运行正常的Bootstrap 3.0 Accordion ,当您单击其中一个主链接时,该 Accordion 将打开。唯一的问题是,如果您单击第二个主链接,则第一个链接不会折叠-它们都保持打开
我正在尝试将 Accordion 嵌入另一个 Accordion 中,但是它不起作用,嵌入式 Accordion 只会扩展到第一个扩展 Accordion 的大小,我需要添加额外的空间才能显示内容,任
我正在尝试将 Accordion 放在 Accordion 中。但是第二个 Accordion 不能正常工作。第一个中的 Accordion 根本不起作用。任何帮助将不胜感激 :) 我的问题主要是代码
我正在尝试创建一个交互式 Accordion / Accordion /折叠动画,以便 View 在与交互时折叠/展开自身 - 以相同的方式 flipboard折叠 View ,但两侧都折叠 我认为我
您好,这是我的第一个问题,英语不是我的母语,如果我犯了一些错误,请见谅。 我在我的项目中使用 Angular 6、jQuery 和 BS。 我有两个 Accordion ,每个都有不同的类别。我们将它
我正在构建一个非常简单的 Accordion ,我想设置 ti 在页面加载时打开所有容器。让它打开单个项目(或没有项目)是没有问题的,但我怎样才能让它打开页面加载时的所有项目。 HTML
我正在处理一个刚刚添加了 Accordion 的页面。它有几个不同的 Accordion ,当单击其中任何一个时,所有 Accordion 都会打开。再次单击 Accordion 时,它应该折叠,但它
尝试弄清楚如何在 Dojo 的 Accordion dijit.layout.Accordion 容器上添加展开/折叠箭头图像,就像 dijitTitlePane / dojox.widget.Tit
我有一个 Accordion ,其中包含一些嵌套的 Accordion ,我打算将其用于移动导航。我不是最擅长 JavaScript,所以我必须找到教程才能达到现在的水平。我现在需要的只是当其他 Ac
我基本上试图关闭所有 Accordion ,只打开其中一个被单击的 Accordion 。 因此,短期内只打开一个选项卡。 这是我到目前为止所拥有的: https://jsfiddle.net/gym
我是一名优秀的程序员,十分优秀!