css - 禁用媒体查询的属性

标签 css

我用纯 html/css 制作了一些网站。

我定义了 overflow-y:当浏览器全屏时滚动到某个元素。

但是当屏幕的宽度小于 400px 时,我想禁用它。 (比如,overflow-y: none。但是 overflow-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

--- 谢谢 ---

关于css - 禁用媒体查询的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51337365/

相关文章:

css - 属性值在 css 上的文本阴影处无效

javascript - FadeOut 和 fadeIn 不工作

html - 如何通过html代码将我的网站设置为浏览器的主页

android - 网页上某些缩放级别的边框

html - 如何使 CSS 锐利 "V"像 `<legend>` 和 `<fieldset>` 的水平 Angular ?

javascript - 在 Bootstrap 中基于父图像重新缩放图像

html - 如何写一个 :hover in inline CSS?

javascript - 使用 Javascript 更改所选文本的 CSS

html - 组织 HTML 文件的标题

html - 如何使所有列的高度与所有列都在同一行的最大列的高度相同?