【发布时间】:2015-07-18 08:58:16
【问题描述】:
我有以下 jQuery Accordion,我想在其中打开多个部分:
$(document).ready(function() {
$(".accordion").accordion({
collapsible: true,
active: false,
animate: 500,
}).on("click", "div", function(e) {
$("div.ui-accordion-header").each(function(i, el) {
if ($(this).is(".ui-state-active")) {
$(this).find(".panel-icon").html("-")
} else {
$(this).find(".panel-icon").html("+")
}
})
});
});
.accordion {
float: left;
line-height: 2.0;
width: 100%;
}
.js_button {
width: 99%;
padding-left: 1%;
font-weight: bold;
border-style: solid;
border-left-width: 1px;
border-right-width: 1px;
border-top-width: 1px;
border-bottom-width: 1px;
margin-top: 1%;
outline-width: 0;
}
.panel {
width: 99%;
height: 20%;
padding-left: 1%;
font-weight: bold;
border-style: solid;
border-left-width: 1px;
border-right-width: 1px;
border-top-width: 0px;
border-bottom-width: 1px;
}
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
</head>
<body class="body">
<div class="accordion">
<div class="js_button"><span class="panel-icon">+</span>Part1</div>
<span class="panel">
<p>Content1</p>
</span>
</div>
<div class="accordion">
<div class="js_button"><span class="panel-icon">+</span>Part2</div>
<span class="panel">
<p>Content2</p>
</span>
</div>
</body>
</html>
手风琴本身工作正常,但是当我使用 Chrome、Safari 或 Opera 时,我的边框底部出现以下问题面板(内容):
当我单击“按钮”并且面板滑出时,边框底部不存在。在幻灯片动画结束时,最终绘制了 bordor-bottom。 我怎样才能避免这种情况,让边框底部从动画开始就在那里,就像在 Firefox 和 IE 中一样?
感谢您的帮助:-)
【问题讨论】:
-
这里也是一个jsfiddle:jsfiddle.net/ypv8yow1
-
我真的不知道,但examples of jQuery UI itself 似乎表现出相同的行为,虽然很难说,因为它们更快且颜色更浅。
-
刚刚更新了我的答案以使动画更流畅 - 希望对您有所帮助?