Why when i use jquery slideDown and Up function, the element cannot be padding or it will be an error
-
13-10-2019 - |
Pergunta
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
Solução
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!
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow