我在这个网站上使用jquery UI accordian:
问题是我无法找到可以保留已打开内容的选项,然后当您点击任何标签时,内容将关闭。
.ui-widget-content {display: block;}
在尝试制作内容类display:block
时,即使点击任何标签页,内容也不会关闭。请帮忙。
答案 0 :(得分:0)
那不再是手风琴,而jquery UI手风琴不支持同时打开多个部分。但是,正如您在this jsbin中看到的那样编写一个如此奇怪的手风琴这一点是微不足道的。
$(document).ready(function() {
$("#odd-accordion h4").click(function() {
$(this).next('div').toggle();
});
});
答案 1 :(得分:0)
jquery UI手风琴没有您想要的选项,但为什么不是定制手风琴:
<强> FIDDLE 强>
<强> ACCORDION FIDDLE WITH EASING PLUGIN 强>
<强> HTML 强>
<div id="accordion">
<h3><a href="#">Section 1</a></h3>
<div class="content">
<p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
</div>
<h3><a href="#">Section 2</a></h3>
<div class="content">
<p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna.</p>
</div>
<h3><a href="#">Section 3</a></h3>
<div class="content">
<p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
</div>
<h3><a href="#">Section 4</a></h3>
<div class="content">
<p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est.</p>
<p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
</div>
</div>
<强> CSS 强>
html {
height: 100%;
background: #e3e3e0;
}
a {
text-decoration: none;
}
:focus, :active {
outline: 0;
}
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#accordion {
width: 500px;
}
#accordion .content {
width: 100%;
background-color: #f3f3f3;
color: #777;
font-size: 10pt;
line-height: 16pt;
font-family:arial;
}
#accordion .content > * {
margin: 0;
padding: 20px;
}
#accordion .content a {
color: #777;
}
#accordion h3 {
background-color: #ccc;
margin: 0px;
}
#accordion h3 a {
color: #fff;
line-height: 42px;
display: block;
font-size: 12pt;
width: 100%;
text-indent: 10px;
text-transform:uppercase;
font-family:arial;
}
#accordion h3 {
background-color: #389abe;
background-image: -moz-linear-gradient(top, #389abe 0%, #2a7b99 100%);
/* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #389abe), color-stop(100%, #2a7b99));
/* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, #389abe 0%, #2a7b99 100%);
/* Chrome10+,Safari5.1+ */
background-image: -o-linear-gradient(top, #389abe 0%, #2a7b99 100%);
/* Opera 11.10+ */
background-image: -ms-linear-gradient(top, #389abe 0%, #2a7b99 100%);
/* IE10+ */
background-image: linear-gradient(to bottom, #389abe 0%, #2a7b99 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#389abe', endColorstr='#2a7b99', GradientType=0);
/* IE6-9 */
}
#accordion h3 a {
text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);
text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);
border-right: 1px solid rgba(0, 0, 0, .2);
border-left: 1px solid rgba(0, 0, 0, .2);
border-bottom: 1px solid rgba(0, 0, 0, .2);
border-top: 1px solid rgba(250, 250, 250, .2);
}
#accordion .content {
box-shadow: inset 0px -1px 0px 0px rgba(0, 0, 0, .4), inset 0px 1px 1px 0px rgba(0, 0, 0, .2);
}
#accordion .content:last-of-type {
box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, .2), inset 0px 0 0px 0px rgba(0, 0, 0, .5);
}
<强> JS 强>
$(function () {
$('#accordion h3').click(function () {
$(this).next().toggle();
return false;
}).next().show();
})