html - 位置静态被破坏

标签 html css

我制作了一个简单的网页并且运行良好,但是由于某种原因,如果我想将 css 中的位置从固定更改为静态,网页就会完全损坏。

我已经尝试过更改 HTML 中的顺序,但它似乎也不起作用...

可能出错的代码在这里:

* {
    box-sizing: border-box;
}

body{
    overflow-x: hidden;
}

.v-header {
    height: 100vh;
    display: flex;
    align-items: center;
    color: #fff;
}

.container {
    max-width: 960px;
    padding-left: 1rem;
    padding-right: 1rem;
    margin: auto;
    text-align: center;
}

.fullscreen-video-wrap{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.fullscreen-video-wrap video {
    min-height: 100%;
    min-width: 100%;
}

.header-overlay {
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    z-index: 1;
    background: #225470;
    opacity: 0.85;
}

.header-content {
    z-index: 2;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.header-content h1{
    font-size: 50px;
    margin-bottom: 0;
}

.header-content p {
    font-size: 1.5rem;
    display: block;
    padding-bottom: 2rem;
}

button {
    background: #34b3a0;
    color: #fff;
    font-size: 1.2rem;
    padding: 1rem 2rem;
    text-decoration: none;
}

.section {
    padding: 20px 0;
}

.section-b {
    background: #333;
    color: #fff;
}

@media(max-width:960px) {
    .container {
        padding-right: 3rem;
        padding-left: 3rem;
    }
}

nav {
    position: fixed;
    z-index: 3;
    background-color: #005EFF;
}

.w3-content {
    z-index: 2;
}

有关更多详细信息和其余代码,这是一个 codepen.io 链接:https://codepen.io/anon/pen/WzWvMP

谢谢,
米格尔

最佳答案

如果你只想改变导航,改变到绝对位置就可以了。

当静态时,它会进入容器,当绝对时,它会扩散。

关于html - 位置静态被破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49784286/

相关文章:

php - HTML 似乎忽略了 PHP 命令?

html - 仅使用 css 更改 div 元素的颜色

JavaScript - 如何知道元素是否为空?

javascript - 我有一个在线工具可以将 HTML 转换为字符串吗?

html - 如何让 Bootstrap 卡片中的图像具有相同的高度/宽度?

html - 通过URL后缀区分HTML文档

jquery - 带有滚动捕捉的水平滚动页面?

css - 是否可以在 LESS 中添加父选择器?

javascript - 单击链接后在同一页面上打开一个窗口

CSS背景图片不显示