【发布时间】:2018-03-26 19:39:16
【问题描述】:
我已经为此工作了一段时间,但我不明白为什么我的 DIV 不能改回显示:无。它从 display: none 在我的 CSS 文件中开始。当您单击按钮时,它会将样式更改为 display = 'block'。我有一个退出标签,我想在单击它时关闭 DIV。我可以使用 visibility = 'hidden' 来做到这一点,但我不明白为什么 display = 'none' 不应该工作。
<button class="btn" onclick="document.getElementById('abo').style.display = 'block';">Learn More</a>
<div id="abo">
<?php include 'about-more.php';?>
<div id="about-more">
<h2>Learn More</h2><br>
<a href="http://youngmarists.org/">For more info on Young Marists</a><br>
<p>Contributers to this website</p>
<?php
foreach($profiles as $profile => $item):
?>
<section class="profile">
<h4 class="name"><?php echo $item['name'];?></h4>
<p class="role"><?php echo $item['role'];?></p>
<img class="profile-img" src="profiles/<?php echo $item['img'];?>"></img>
</section>
<?php endforeach;?>
<i class="fa fa-times-circle fa-2x" onclick="document.getElementById('abo').style.display = 'none';"; style="position:fixed;top:6%;right:18%;"></i>
</div>
【问题讨论】:
-
可见性:当您同时使按钮和退出标签可见而不是显示时,隐藏实际上不起作用。
标签: javascript html css