html - 如何在加载另一个页面时自动关闭DIV

标签 html css expand

通过使用下面的 css,我可以在单击按钮时展开 div。 这个 DIV 固定在每个页面的顶部。 但即使我移动到另一个页面,它也总是以展开的形式出现。 如何在加载其他页面时自动关闭它?

#expend {
  display:none;  
}

#expend + .smalldesc {
  max-height:52px;
  overflow:hidden;
  transition:all .3s ease;
}

#expend:checked + .smalldesc {
  max-height:250px;  
}

label {
  color:blue;
  text-decoration:underline;
  cursor:pointer;
}

label:hover {
  text-decoration:none;  
}
<div class="service-1 click1">
<div class="row">
  <input type="checkbox" id="expend" />
  <div class="medium-12 small-12 columns smalldesc">
  <p class="font16 ">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </p>
  </div>
  <label for="expend">Read More</label>
</div>
</div>

最佳答案

如果您在每个页面上添加它,它会将复选框设置为未选中:

<script type="text/javascript">
    $(document).ready(function() {
        $('#expend').prop('checked', false);
    });
</script>

关于html - 如何在加载另一个页面时自动关闭DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53856532/

相关文章:

css - <a> 标签中的边距不可点击(Foundation 4)

html - 左对齐表格不适用于 CSS,但适用于 HTML

javascript - 在时间轴上定位条目

java - 自定义 Ant 任务中的扩展属性

search - 使用扩展区域在 emacs 中更好地搜索

html - 与 Capybara 中深度嵌套的单选按钮交互

css - 维护子div定位

php - 使用 php 和 jquery 解决简单任务的想法

html - 垂直对齐 Font Awesome 图标与 <li> 中的文本

javascript - jqgrid 组展开/折叠事件