css - 禁用媒体查询属性
问题描述
我用纯 html/css 制作了一些网站。
我定义了溢出-y:当浏览器全屏时滚动到某个元素。
但是当屏幕宽度小于 400 像素时,我想禁用它。(例如,溢出-y:无。但溢出-y 没有)
有什么解决办法吗?
解决方案
您可以只使用 ***overflow: auto;
然后它工作正常参见示例。
#overflowTest {
background: #4CAF50;
color: white;
padding: 15px;
width: 200px;
height: 200px;
overflow: scroll;
border: 1px solid #ccc;
}
#overflowauto {
background: #4CAF50;
color: white;
padding: 15px;
width: 200px;
height: 200px;
overflow: auto;
border: 1px solid #ccc;
}
<h2>overflow scroll</h2>
<div id="overflowTest">This text is really long and the height of its container is only 100 pixels. Therefore, a scrollbar is added to help the reader to scroll the content. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </div>
<h2>overflow auto</h2>
<div id="overflowauto">This text is really long and the height of its container is only 100 pixels. Therefore, a scrollbar is added to help the reader to scroll the content. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt property-on-media-query# laoreet dolore magna aliquam erat volutpat. </div>
您可以了解有关溢出属性的更多信息https://www.w3schools.com/css/css_overflow.asp
- - 谢谢你 - -
推荐阅读
- airpush - AirPush SDK 包含在 App Bundle google play 中
- javascript - 在 React Js 中使用 Grids 和 Map 生成表
- c# - 如何按索引调用嵌套 OrderedDictionary 中元素的方法
- python - 如何将 js 变量发送到我的 python 服务器?
- python-3.x - 当我尝试将烧瓶路由重定向到有效端点时,它给了我 404 Page not Found
- reactjs - 如何使用 react hooks 和 redux 设置私有路由?
- sql - 如何正确设计决策树?
- visual-studio-code - 如何使更漂亮的(php)与 VS Code 一起工作
- python - 我得到这个错误''IndexError:列表索引超出范围''
- flutter - screenutil 导入但卡在 ScreenUtil.init(context, width: 350, height: 660,);