我的导航栏不会显示在屏幕顶部

问题描述 投票:0回答:1

我的导航不会显示在页面顶部,我尝试了 z-index 和所有内容,但如果我删除变换,则会出现栏,但占据了一半的屏幕。

<!DOCTYPE html>

<html>
    <head>
        <title>My Portfolio</title>
        <link  rel="stylesheet" href="styles.css">
        <meta charset="UTF-8">
        <meta name="viewport"> 
    </head>
    <body>
        <section id="welcome-section">
            <header>
                <h1 class="title">Hey I am Matija</h1>
                <p class="welcum">a web developer</p>
            </header>   
        </section>  
        <nav class="nav"></nav>
            <ul class="navbar">
                <li>
                    <a href="#welcome-section">About</a>
                </li>
                <li>
                    <a href="#projects">Work</a>
                </li>
                <li>
                    <a href="#contact">Contact</a>
                </li>
            </ul>
        </nav> 
        <div class="background">
        </div>
        <section class="project">
            <div class="projects">
            </div>
        </section>
        <section class="recruit">
            <div class="contact"></div>
        </section>
    </body>

 
    margin: 0;
    padding: 0;
}

.nav{
    z-index: 300;
    display: flex;
    justify-content: flex-end;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: red;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

h1,p{ 
    color: white;
    padding: 0;
    margin: 0;   
}

body{
    z-index: 100;
    position: relative;
    display: flex;
    width: auto;
    height: 100vh;
    border-radius: 0px;
    background-image: linear-gradient(62deg, #3a3d40 0%, #181719 100%); 
    margin : 0;
    padding: 0;
}

#welcome-section{
    justify-content: center;
    display: block;
    margin: 0 auto;
    z-index: 1000;
    text-align: center;
    margin-top: 160px;
}

h1{
    font-family: 'Poppins', sans-serif;
    font-size: 50px;
    font-weight: 150;
    padding-top: 200px;
}

.welcum {
    z-index: 2;
    font-size: 1.4rem;
    font-weight:0;
    font-style: italic;
    color: orangered;
    font-family: 'Poppins', sans-serif;
}

html{
    scroll-behavior: smooth;
}

无论我做什么,导航都不会显示

html css navbar nav
1个回答
0
投票

删除

</nav>
之后
<nav class="nav>
然后运行代码

© www.soinside.com 2019 - 2024. All rights reserved.