Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 内容重叠固定导航栏_Html_Css - Fatal编程技术网

Html 内容重叠固定导航栏

Html 内容重叠固定导航栏,html,css,Html,Css,有人能帮我解释为什么会这样吗 我正在为我的大学作业创建一个网站,当我尝试创建固定的响应导航栏时,遇到了这个问题。当我向下滚动时,主体内容(如或)将与固定导航栏重叠 以下是我的HTML代码: <html lang= "en"> <head> <meta charset="utf-8"> <title>Tanat Resort</title> <meta name="viewp

有人能帮我解释为什么会这样吗

我正在为我的大学作业创建一个网站,当我尝试创建固定的响应导航栏时,遇到了这个问题。当我向下滚动时,主体内容(如或)将与固定导航栏重叠

以下是我的HTML代码:

<html lang= "en">
    <head>
        <meta charset="utf-8">
        <title>Tanat Resort</title>
        <meta name="viewport" content="width=device-width, initial-scale= 1">
        <link rel="stylesheet" href="css/style.css"/>
        <script src="js/jquery-3.5.1.min.js"></script>
        <script src="js/main.js"></script>

    </head>
    <body>
        <nav class="navbar">
            <a href="index.html" class="logo">TANAT RESORT</a>
            <ul class="desktop-list">
                <li class="desktop-menu"><a href="resident.html">Resident</a></li>
                <li class="desktop-menu"><a href="event.html">event</a></li>
                <li class="desktop-menu"><a href="more.html">More..</a></li>
                <li class="desktop-menu" id="book-button"><a href="#" id="book-menu">Book now</a></li>
            </ul>
            <a href="#" class="burger-menu" onclick="myFunction(this)">
                <div class="menulogo1"></div>
                    <div class="menulogo2"></div>
                    <div class="menulogo3"></div>
            </a>

            <ul id="responsive-menu">
                <li class="hidden-menu"><a href="index.html">Home</a></li>
                <li class="hidden-menu"><a href="resident.html">Resident</a></li>
                <li class="hidden-menu"><a href="event.html">event</a></li>
                <li class="hidden-menu"><a href="more.html">More..</a></li>
                <li class="hidden-menu"><a href="more.html">About us</a></li>
                <li class="hidden-menu"><a href="#">Contact</a></li>

            </ul>
        </nav>

        <section id="search-bar">
            Search bar here
        </section>

        <article>
            <section class="main-article">
                <h1>Discover the most adventurous resort in the world</h1>
                <h1>Tanat's Resort</h1>
            </section>

            <section class="main-galleries">
                <img class = "banner-img" src="images/beach-top-view.jpg" alt="beach">

                <article class="gallery-articles">
                    <h2>Experience</h2>
                    <p>Beach, ocean, volcano. </p>
                    <a href="#" class="more-buttons">DISCOVER MORE</a>
                </article>
            </section>

            <section class="main-galleries">
                <img class = "banner-img" src="images/bird-s-eye-view-photo-of-cabanas-1456293.jpg" alt="resort view from top">

                <article class="gallery-articles">
                    <h2>Our resident</h2>
                    <p>"Would you like to buy a vowel?" printed on the front. He listens carefully to Mark’s diagnosis. Then he unshoulders his heavy hoe and starts digging.</p>
                    <a href="#" class="more-buttons">DISCOVER MORE</a>
                </article>
            </section>

            <section class="main-galleries">
                <img class = "banner-img" src="images/lava-flowing-1687530.jpg" alt="lava flowing picture">

                <article class="gallery-articles">
                    <h2>Activities</h2>
                    <p>Test 12345</p>
                    <a href="#" class="more-buttons">DISCOVER MORE</a>
                </article>

            </section>

            <article id="slide-galleries">
                <p>Slide Galleries</p>
            </article>

        </article>

        <footer>
            <section>
                <p>Footer</p>
                <p>Footer</p>
                <p>Footer</p>
                <p>Footer</p>
                <p>Footer</p>
            </section>
        </footer>

    </body>
</html>```

and CSS code (I only provide the responsive css code)




@media screen and (max-width: 768px) {
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    body {
        overflow-x:hidden;
    }

    .navbar {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        background-color: white;
        list-style-type: none;
        position: fixed;
        top: 0;
        width: 100%;
        border-bottom-style: solid;
        border-color: grey;
    }

    a {
        display: block;
        color: black;
        text-decoration: none;
        margin: 5px 15px;
    }

    .desktop-menu {
        display: none;
    }


    .burger-menu {
        margin-right: 15px;
        cursor: pointer;
    }

    #dropdown-menu {
        position: absolute;
        width: 100%;
        height: 50%;
        top: 33px;
        display: flex;
        position: fixed;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;
        background-color: whitesmoke;
        list-style: none;
        border: 1px solid;
        border-color: grey;
        display:none;
    }

    .hidden-menu { 
        display: block;
        text-transform: uppercase;
        font-size: 20px;
        color: white;
    }

    .hidden-menu:hover { 
        cursor: pointer;
        border-bottom: 1px solid;
        border-color: grey;
    }


    /*burger menu*/
    div.menulogo1, div.menulogo2, div.menulogo3 {
        width: 30px;
        height: 3px;
        background-color: black;
        margin: 6px 0;
        transition: 0.4s;
    }

    /*transition from 3 bar to x bar*/

    /*first bar of menu logo*/
    .change .menulogo1 {
        -webkit-transform: rotate(-45deg) translate(-6px, 3px);
        transform: rotate(-45deg) translate(-6px, 3px);
    }

    /*delete second bar*/
    .change .menulogo2 {
        opacity: 0;
    }

    /* third bar rotate*/
    .change .menulogo3 {
        -webkit-transform: rotate(45deg) translate(-8px, -8px);
        transform: rotate(45deg) translate(-8px, -8px)
    }



    /*body part start here*/
    #search-bar {
        margin: 70px 20px 10px;
        background-color: olive;
    }

    .main-article {
        display: none;
    }

    .main-galleries {
        padding: 20px 15px 15px;
        display: flex;
        flex-direction: column;
    }

    .main-galleries h2 {
        margin: 10px 0px 10px;
        padding: 5px;
    }

    .gallery-articles {
        padding: 10px;
        text-align: center;
    }

    .gallery-articles h2 {
        font-size: 25px;
        text-transform: uppercase;
        padding: 15px 0px 15px;
        margin-bottom: 20px;
        border-bottom-style: solid;
        border-color: grey;
    }

    .gallery-articles a {
        display: block;
        margin-top: 40px;
        padding: 10px 15px;
        cursor: pointer;
        border: none;
        color: white;
        background-color: black;
        text-align: center;
        transition: 0.3s;
        opacity: 0.7;
    }

    .gallery-articles a:hover {
        opacity: 1;
    }

    .banner-img {
        margin: auto;
        width: 90%;
    }

    #slide-galleries {
        background-color: gold;
    }

    footer {
        background-color: grey;
    }
}

塔纳特度假村
搜索栏在这里 幻灯片库

页脚

页脚

页脚

页脚

页脚

``` 和CSS代码(我只提供响应CSS代码) @媒体屏幕和屏幕(最大宽度:768px){ * { 保证金:0; 填充:0; 框大小:边框框; } 身体{ 溢出x:隐藏; } navbar先生{ 显示器:flex; 弯曲方向:行; 证明内容:之间的空间; 对齐项目:居中; 背景色:白色; 列表样式类型:无; 位置:固定; 排名:0; 宽度:100%; 边框底部样式:实心; 边框颜色:灰色; } a{ 显示:块; 颜色:黑色; 文字装饰:无; 利润率:5px15px; } .桌面菜单{ 显示:无; } .汉堡菜单{ 右边距:15px; 光标:指针; } #下拉菜单{ 位置:绝对位置; 宽度:100%; 身高:50%; 顶部:33px; 显示器:flex; 位置:固定; 弯曲方向:立柱; 证明内容:周围的空间; 对齐项目:居中; 背景色:白烟; 列表样式:无; 边框:1px实心; 边框颜色:灰色; 显示:无; } .隐藏菜单{ 显示:块; 文本转换:大写; 字体大小:20px; 颜色:白色; } .隐藏菜单:悬停{ 光标:指针; 边框底部:1px实心; 边框颜色:灰色; } /*汉堡菜单*/ 分区菜单组1、分区菜单组2、分区菜单组3{ 宽度:30px; 高度:3倍; 背景色:黑色; 利润率:6px0; 过渡:0.4s; } /*从3巴过渡到x巴*/ /*菜单标志的第一栏*/ .change.menulogo 1{ -webkit变换:旋转(-45度)平移(-6px,3px); 变换:旋转(-45度)平移(-6px,3px); } /*删除第二条*/ .change.menulogo 2{ 不透明度:0; } /*第三棒旋转*/ .change.menulogo3{ -webkit变换:旋转(45度)平移(-8px,-8px); 变换:旋转(45度)平移(-8px,-8px) } /*身体部位从这里开始*/ #搜索栏{ 利润率:70像素20像素10像素; 背景颜色:橄榄色; } .主要文章{ 显示:无; } .主廊{ 填充:20px 15px 15px; 显示器:flex; 弯曲方向:立柱; } ·主廊h2{ 保证金:10px 0px 10px; 填充物:5px; } .画廊文章{ 填充:10px; 文本对齐:居中; } .画廊文章h2{ 字体大小:25px; 文本转换:大写; 填充:15px 0px 15px; 边缘底部:20px; 边框底部样式:实心; 边框颜色:灰色; } .画廊文章a{ 显示:块; 边缘顶端:40px; 填充:10px 15px; 光标:指针; 边界:无; 颜色:白色; 背景色:黑色; 文本对齐:居中; 过渡:0.3s; 不透明度:0.7; } .画廊文章a:悬停{ 不透明度:1; } .banner img{ 保证金:自动; 宽度:90%; } #幻灯片库{ 背景颜色:金色; } 页脚{ 背景颜色:灰色; } }
我想我解决了你的问题。您只需将
z-index:999
(或任何其他高数值)添加到导航栏

像这样:

.navbar {
   z-index: 999;
}

这使得它可以在
999
以下的
z-index
的所有内容之上。您可以了解有关
z-index
属性的更多信息。我希望这有帮助

我想我解决了你的问题。您只需将
z-index:999
(或任何其他高数值)添加到导航栏

像这样:

.navbar {
   z-index: 999;
}

这使得它可以在
999
以下的
z-index
的所有内容之上。您可以了解有关
z-index
属性的更多信息。我希望这有帮助

示例图片在哪里?请同时提供,以便我能理解您的查询better@OmChaudhary图片意外链接错误,因此,您必须滚动到答案中代码的底部才能查看。无论如何,可以在示例图片的位置查看图像?请同时提供,以便我能理解您的查询better@OmChaudhary这幅画被意外地连在一起了