html - 页脚不会在较小的屏幕上隐藏

标签 html css media-queries

我正在为一个元素开发 Javascript 技术文档页面,但我使用媒体查询的页脚并没有像我希望的那样隐藏在小屏幕上。

尝试过的事情:

  • 更改位置固定,这导致页脚完全消失
  • 显示:无;
  • 高度和宽度设置为 0px;

这是我的 SASS 代码,它已正确链接到 html 页面和 CSS。

footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    text-align: center;
    padding-top: 30px;
    padding-bottom: 5px;
}

@media only screen and (max-width:400px) {

    footer {
        display:none;

    }
}
<footer>
        Designed and Coded by: 
        <a href="what i linked" target="_blank">my name</a>
    </footer>

我认为这是我所缺少的非常简单的东西,但我是新手,所以我想寻求帮助。

非常感谢您,感谢您的宝贵时间。

最佳答案

添加<meta content="width=device-width, initial-scale=1" name="viewport" />在它为你工作之前。

    footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    text-align: center;
    padding-top: 30px;
    padding-bottom: 5px;
}

@media only screen and (max-width:400px) {
    footer {
        display:none;

    }
}
    <meta content="width=device-width, initial-scale=1" name="viewport" />

    <footer>
        Designed and Coded by: 
        <a href="what i linked" target="_blank">my name</a>
    </footer>

照片:enter image description here

关于html - 页脚不会在较小的屏幕上隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71121134/

相关文章:

html - div相对重叠

HTML/CSS : How to resize checkboxes (without overlapping)

html - 在两个 div 之间居中 div

html - 字体标签悬停在 firefox 上不起作用,但在 chrome 上正常工作

css - IE9 css 媒体查询无法正常工作......在其他任何地方都可以正常工作

html - 折叠边栏菜单 Flex

javascript - 单击按钮时显示文本框

css - 没有媒体类型的@media 规则是做什么的?

html - 是否可以在 css 中组合 2 种背景颜色?

iphone - 媒体查询不适用于 iPhone 的邮件