首页 > 解决方案 > 确定元素之间的边距

问题描述

可以说我有 3 个元素。

<h2>test<h2>
<h2 style="visibility: visible" >test1<h2>
<h2>test2<h2>

现在通过java脚本我有时想隐藏test1,没问题。但是当发生这种情况时,我希望 test2 在测试下方。在 test1 隐藏的那一刻, test 和 test2 之间有一个空白空间。当 test1 隐藏时,我尝试通过更改 test2 的 margin-top 来做到这一点,但没有任何反应。

  if (condition is true, change the margin-top of test2)

标签: htmlcss

解决方案


推荐阅读