为什么当我使用jquery的slideDown和Up函数时,元素不能填充,否则会出错

发布于 2024-10-08 18:06:02 字数 164 浏览 0 评论 0原文

下面是我的带有填充的代码

'#'expand{ 内边距:16px;显示:无;背景颜色:#fff; }

时,看起来填充是用幻灯片动画的,

而不是我需要放置一个子 div 元素并将填充放入子元素中,我可以问一下吗

Below is my code with padding

'#'expand{ padding: 16px; display: none; background-color: #fff; }

when i put slidetoggle to this element, it seems like the padding animated with the slide

Instead i need a put an child div element and put padding in the child element, Can I ask

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿越时光隧道 2024-10-15 18:06:02

我不太确定这就是您想要的,但我假设您想将子 div 滑入带有填充的父 div 中。你可以这样做:

HTML:

<div id="container">
    <div id="expand">Stuff goes here</div>
</div>

CSS:(

#expand{      
    display: none;    
    background-color: yellow;
}
#container {
    padding:16px;
    background-color:black;
}

颜色是为了强调填充元素)

JavaScript:

$("#button").click(function() {
    $("#expand").slideToggle();
});

示例如下: http://jsfiddle.net/andrewwhitaker/hqVdQ/

希望有帮助!

I'm not exactly sure this is what you want, but I'm assuming you want to slide a child div into a parent div with padding. You could do something like this:

HTML:

<div id="container">
    <div id="expand">Stuff goes here</div>
</div>

CSS:

#expand{      
    display: none;    
    background-color: yellow;
}
#container {
    padding:16px;
    background-color:black;
}

(Colors are there for emphasis of the padded elements)

JavaScript:

$("#button").click(function() {
    $("#expand").slideToggle();
});

Example here: http://jsfiddle.net/andrewwhitaker/hqVdQ/

Hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文