css - CSS:目标+滚动条
问题描述
当弹出目标处于活动状态时,我可以隐藏滚动条吗?只有CSS。
div {display: none}
#popup:target{display: block;}
<a href="#popup">Popup</a>
<a href="#">Del</a>
<div id="popup">
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
content<br>
</div>
解决方案
我觉得没关系。我想要做的是,当#popup:target 处于活动状态时,BODY,也许 HTML 标记将是 {overflow: hidden}
我试过了
#popup:target:active + body {overflow: hidden;}
#popup:target ~ body {overflow: hidden;}
但什么都没有。
我用 jQuery 做了这个,效果很好!但是我可以用纯 CSS 来做吗?泰
var url = window.location.hash;
$(function(){
if (url.substring(url.indexOf('#'))){
$("html, body").css({
overflow: 'hidden',
height: '100%'
});
}
$("#isnt-scroll").click(function() {
$("html, body").css({
overflow: 'hidden',
height: '100%'
});
});
});
推荐阅读
- android - 如何在滑动中居中对齐图标以以编程方式删除recyclerview
- ios - Codemagic 未在 Appstore Connect 中卸载颤振应用程序集
- firebase - 当他在firebase上的数据发生变化时如何向用户发送通知
- sql - 创建月份函数
- java - 如何转换数据值?
- css - 如何为自定义选择制作下拉 CSS 动画?
- javascript - 链接到新的动态路由不会改变 getInitialProps 数据
- r - 有没有办法在 Shiny 中预缓存输出?
- python - 设置要在 Jupyter Notebook 中使用的 Python 版本以实现可重复性
- php - php-fpm(池)错误。- 指定的超时已过期