html - 固定在标题上的 Css 位置隐藏了内容

标签 html css header position

我正在创建一个新网站,但标题有问题...我将标题的位置设置为固定,这有效但标题下方的内容被隐藏了。我尝试使用 margin-top: 10px 将内容向下移动,但它所做的只是将标题向下移动。

jsfiddle 链接:

http://jsfiddle.net/vwzhda41/

最佳答案

padding-top:58px; 添加到 .responsiveContainer 并将 top:0; 添加到 .header.

Jsfiddle

.responsiveContainer {
    width: 100%;
    // Add padding top
    padding-top: 58px;
}

.header {
    background-color: #000000;
    padding: 10px;
    padding-left: 0;
    padding-right: 0;
    box-shadow: 0 5px 0 #232323;
    text-align: center;
    width: 100%;
    position: fixed;
    //   Add top 0
    top: 0;
}

根据 MDN :

fixed

Do not leave space for the element. Instead, position it at a specified position relative to the screen's viewport and don't move it when scrolled. When printing, position it at that fixed position on every page. This value always create a new stacking context.

关于html - 固定在标题上的 Css 位置隐藏了内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33439883/

相关文章:

javascript - Internet Explorer 中的日期选择器错误

html - 如何使用 Golang 检索所选 HTML 元素的高度?

jquery - 单击子菜单时将类添加到父菜单

header - 当头文件更改时 GNU-Make 不会重新编译

javascript - 在服务 worker 中读取请求 header

html - 网站开发简单

javascript - 灯箱不会触发 onclick

CSS3 背景不透明度与背景图像

javascript - 脚本有效但有错误 : Uncaught TypeError: Cannot read property 'classList' of null at HTMLAnchorElement

c++ - g++坏了?无法向类添加新方法