[英]Vertically aligning animated divs
I have three buttons that set different output text when clicked and I'm trying to use W3.CSS animations to "slide" the text in and out.我有三个按钮,它们在单击时设置不同的输出文本,我正在尝试使用 W3.CSS 动画将文本“滑入”和“滑出”。 I almost have it working using two separate divs but cannot get them to align correctly under the buttons;我几乎让它使用两个单独的 div 工作,但无法让它们在按钮下正确对齐; the div for every other button click displays lower than the previous one.每隔一个按钮点击的 div 显示低于前一个。
I've tried float
, vertical-align: top
, display: inline-block
, and a few other things so far but either used them incorrectly or something else (a conflicting parent div style, maybe?) is causing problems.到目前为止,我已经尝试过float
、 vertical-align: top
、 display: inline-block
和其他一些东西,但要么使用不当,要么其他东西(可能是父 div 样式冲突?)导致问题。
Image with a button's output displaying right under the buttons (as it should)按钮输出显示在按钮正下方的图像(应该如此)
Image with the next button's output displaying lower than the first下一个按钮的输出显示低于第一个按钮的图像
I trimmed code that wasn't relevant while also leaving what was necessary to show the div structure for this particular section.我修剪了不相关的代码,同时也留下了显示此特定部分的 div 结构所需的内容。
old_output
and new_output
are what I'm trying to align below the buttons HTML:ID 为old_output
和new_output
的 div 是我试图在按钮下方对齐的div.button_output_container
and div.button_output
are used for the output divs and their container CSS: div.button_output_container
和div.button_output
用于输出 div 及其容器I am not sure I totally understand your alignment requirement, but if you just want your divs to render on the same height, you could opt for position:absolute
like so:我不确定我是否完全理解你的对齐要求,但如果你只是想让你的 div 呈现在相同的高度,你可以选择position:absolute
像这样:
div.button_output_container {
position: relative;
}
div.button_output {
margin: 16px 24px;
width: 450px;
position: absolute;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.