如果
我有这个 div,它确实有动画,但是一旦通过 DIV 内的列表,它只会使 DIV 可见,并且一旦动画到达列表高度的底部,您就可以看到它有动画!
然后单击顶部菜单上的“产品”选项。
我的 jQuery 是:
$(function() {
$('.productRangeActivator').click(function(){
$('.productRange').animate({'height': '310px'}, 1000);
$('.productRange').css({'overflow': 'visible'}, 1000);
});
});
HTML 是:
<div class="productRange">
<div class="hardware">
<span>
<h1>Hardware</h1>
<ul class="productList">
<li><a href="@Href("~/Products/Hardware/hardware_dynabolts-anchors.cshtml")">Dynabolts & Anchors</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_wire-rope.cshtml")">Wire Rope</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_swage-terminals-balustrading.cshtml")">Swage Terminals & Balustrading</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_rigging-screws-turnbuckles.cshtml")">Rigging Screws & Turnbuckles</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_eye-bolts-screws.cshtml")">Eye Bolts & Screws</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_swaging-cutting-tools.cshtml")">Swaging & Cutting Tools</a></li>
</ul>
</span>
</div>
<div class="stainlessSteel">
<span>
<h1>Stainless Steel</h1>
<ul class="productList">
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_allthread.cshtml")">Allthread</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_hex-bolts.cshtml")">Hex Bolts</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_hex-setscrews.cshtml")">Hex Setscrews</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_hex-nuts.cshtml")">Hex Nuts</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_flat-washers.cshtml")">Flat Washers</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_socket-screws.cshtml")">Socket Screws</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_screws.cshtml")">Screws</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_cup-head-bolts.cshtml")">Cup Head Bolts</a></li>
</ul>
</span>
</div>
<div class="mildSteel">
<span>
<h1>Mild Steel</h1>
<ul class="productList">
<li><a href="@Href("~/Products/MildSteel/mildsteel_allthread.cshtml")">Allthread</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_hex-nuts.cshtml")">Hex Nuts</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_washers.cshtml")">Washers</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_hex-nut-bolt-kits-setscrews.cshtml")">Hex Nut & Bolt Kits, Setscrews</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_screws.cshtml")">Screws</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_cup-head-bolts-nuts.cshtml")">Cup Head Bolts & Nuts</a></li>
</ul>
</span>
</div>
<div class="highTensile">
<span>
<h1>High Tensile</h1>
<ul class="productList">
<li><a href="@Href("~/Products/HighTensile/hightensile_allthread.cshtml")">Allthread</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_bolt-nut-kits-screws.cshtml")">Bolt & Nut Kits, Screws</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_hex-nuts-flat-washers.cshtml")">Hex Nuts & Flat Washers</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_structural-kits.cshtml")">Structural Kits</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_socket-screws.cshtml")">Socket Screws</a></li>
</ul>
</span>
</div>
</div>
CSS:
.productRange {
width: 100%;
height: 0;
overflow: hidden;
}
.hardware {
padding: 0 0 0 25px;
height: 250px;
float: left;
overflow: hidden;
}
.stainlessSteel {
padding: 0 0 0 30px;
height: 250px;
float: left;
overflow: hidden;
}
.mildSteel {
padding-left: 45px;
height: 250px;
float: left;
overflow: hidden;
}
.highTensile {
padding-left: 35px;
height: 250px;
float: left;
overflow: hidden;
}
I had this div, that DID animate, but as soon as a through a list inside the DIVs, it only makes the DIV visible, and once the animate has gone to the bottom of the height of the lists, then you can see it animate!
And click on the Products option on the top menu.
My jQuery is:
$(function() {
$('.productRangeActivator').click(function(){
$('.productRange').animate({'height': '310px'}, 1000);
$('.productRange').css({'overflow': 'visible'}, 1000);
});
});
And the HTML is:
<div class="productRange">
<div class="hardware">
<span>
<h1>Hardware</h1>
<ul class="productList">
<li><a href="@Href("~/Products/Hardware/hardware_dynabolts-anchors.cshtml")">Dynabolts & Anchors</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_wire-rope.cshtml")">Wire Rope</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_swage-terminals-balustrading.cshtml")">Swage Terminals & Balustrading</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_rigging-screws-turnbuckles.cshtml")">Rigging Screws & Turnbuckles</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_eye-bolts-screws.cshtml")">Eye Bolts & Screws</a></li>
<li><a href="@Href("~/Products/Hardware/hardware_swaging-cutting-tools.cshtml")">Swaging & Cutting Tools</a></li>
</ul>
</span>
</div>
<div class="stainlessSteel">
<span>
<h1>Stainless Steel</h1>
<ul class="productList">
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_allthread.cshtml")">Allthread</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_hex-bolts.cshtml")">Hex Bolts</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_hex-setscrews.cshtml")">Hex Setscrews</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_hex-nuts.cshtml")">Hex Nuts</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_flat-washers.cshtml")">Flat Washers</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_socket-screws.cshtml")">Socket Screws</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_screws.cshtml")">Screws</a></li>
<li><a href="@Href("~/Products/StainlessSteel/stainlesssteel_cup-head-bolts.cshtml")">Cup Head Bolts</a></li>
</ul>
</span>
</div>
<div class="mildSteel">
<span>
<h1>Mild Steel</h1>
<ul class="productList">
<li><a href="@Href("~/Products/MildSteel/mildsteel_allthread.cshtml")">Allthread</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_hex-nuts.cshtml")">Hex Nuts</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_washers.cshtml")">Washers</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_hex-nut-bolt-kits-setscrews.cshtml")">Hex Nut & Bolt Kits, Setscrews</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_screws.cshtml")">Screws</a></li>
<li><a href="@Href("~/Products/MildSteel/mildsteel_cup-head-bolts-nuts.cshtml")">Cup Head Bolts & Nuts</a></li>
</ul>
</span>
</div>
<div class="highTensile">
<span>
<h1>High Tensile</h1>
<ul class="productList">
<li><a href="@Href("~/Products/HighTensile/hightensile_allthread.cshtml")">Allthread</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_bolt-nut-kits-screws.cshtml")">Bolt & Nut Kits, Screws</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_hex-nuts-flat-washers.cshtml")">Hex Nuts & Flat Washers</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_structural-kits.cshtml")">Structural Kits</a></li>
<li><a href="@Href("~/Products/HighTensile/hightensile_socket-screws.cshtml")">Socket Screws</a></li>
</ul>
</span>
</div>
</div>
And the CSS:
.productRange {
width: 100%;
height: 0;
overflow: hidden;
}
.hardware {
padding: 0 0 0 25px;
height: 250px;
float: left;
overflow: hidden;
}
.stainlessSteel {
padding: 0 0 0 30px;
height: 250px;
float: left;
overflow: hidden;
}
.mildSteel {
padding-left: 45px;
height: 250px;
float: left;
overflow: hidden;
}
.highTensile {
padding-left: 35px;
height: 250px;
float: left;
overflow: hidden;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要在
div
完全动画化后设置溢出:我还建议您将
.productRange
的高度更改为 0px 而不仅仅是 0,只是为了确保jQuery 不会出现故障。I think you need to set the overflow after you
div
has animated fully:I would also suggest you change
.productRange
's height to 0px not just 0, just to make sure jQuery doesn't glitch.据我所知,产品范围的默认高度值为 250px。动画开始播放,但我猜它从 250 像素开始到 310 像素。由于只需要 250 像素即可显示所有内容,因此看起来根本没有动画。所以动画是完美的,只要确保类 .productRange 确实从 0px 开始,我很确定它会没问题。
From what i see, product range as a default height value of 250px. The animation goes but i guess it starts from 250px to 310 pixels. Since you only need 250px to display all the stuffs, it looks like there'S no animation at all. So the anim is perfect, just make sure the class .productRange does start at 0px and I'm pretty sure it'll be fine.