我能够得到你所追求的外观,没有“跳跃”,使用下面的手风琴方法,看起来这可能是两个选项中更好的一个。
手风琴法
jQuery UI 手风琴
jsFiddle
css
a {
text-decoration: none;
color: #252525;
}
.bar {
border-radius: 6px;
box-shadow: 0 0 0 1px #bbb;
height: 34px;
border: 1px solid #eacec3 !important;
background: #ddb09e;
/* Old browsers */
filter: none !important;
box-shadow: inset 0 -17px 30px 0 #c98c75, 0 0 0 1px #84413f;
width: 400px;
margin-bottom:0.5em;
}
.text {
background: #fff;
border: 1px solid #aaa;
border-radius: 6px;
font: 14px'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;
padding: 10px;
width: 365px;
}
.title {
float: left;
font: bold 17px'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;
line-height: 35px;
margin-left: 12px;
text-decoration: none !important;
text-shadow: -1px -1px 0px rgba(0, 0, 0, 0.2), 1px 1px 0px rgba(255, 255, 255, 0.3);
vertical-align: middle;
}
.ui-accordion .ui-accordion-header {
display: block;
cursor: pointer;
position: relative;
padding:0;
}
.ui-accordion .ui-accordion-content {
padding: 1em 1.2em;
border-top: 1px solid #aaa;
overflow: auto;
}
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited {
color: #000;
text-decoration: none;
}
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
background:none;
font-weight: normal;
color: #fff;
width:400px;
border: 1px solid #fff;
}
.ui-accordion .ui-accordion-header .ui-accordion-header-icon {
position: absolute;
left: 0;
top: 40%;
margin-top: -8px;
}
js
$(function () {
$("#accordion").accordion({
collapsible: true,
active: false
});
});
html
<div id="accordion">
<div>
<div class="bar"> <a href="#" class="title">Slide #1</a>
</div>
</div>
<div class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br>
<form>Text:
<input type="text">
<br>
<input type="checkbox">
<br>
<input type="radio">
<br>
<input type="button" value="Button">
</form>
</div>
slideDown / slideUp 方法
不那么干净,但我得到了大部分的使用box-sizing:border-box;
和重组的东西。仍然有轻微的闪烁,但也许这会引导您朝着正确的方向前进。
jsFiddle2
css
a {
text-decoration: none;
color: #252525;
}
.slide {
padding-bottom: 15px;
width: 400px;
}
.bar {
border-radius: 6px;
box-shadow: 0 0 0 1px #bbb;
height: 34px;
border: 1px solid #eacec3 !important;
background: #ddb09e;
/* Old browsers */
filter: none !important;
box-shadow: inset 0 -17px 30px 0 #c98c75, 0 0 0 1px #84413f;
width: 400px;
margin-bottom:0.25em;
}
.text {
background: #fff;
border: 1px solid #aaa;
border-radius: 6px;
font: 14px'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;
padding: 10px;
width: 400px;
box-sizing:border-box;
-moz-box-sizing:border-box;
}
.title {
float: left;
font: bold 17px'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;
line-height: 35px;
margin-left: 12px;
text-decoration: none !important;
text-shadow: -1px -1px 0px rgba(0, 0, 0, 0.2), 1px 1px 0px rgba(255, 255, 255, 0.3);
vertical-align: middle;
}
更新:我怀疑动画计算中可能存在错误.slideDown()
,.slideUp()
如果您将其更改为.show()
并且.hide()
跳转消失。
jsFiddle3