导航集成后不再显示HTML图片

时间:2019-07-09 16:58:53

标签: javascript html css

我正在建立一个响应式网站,添加响应式导航后,分配给div“ .hero-image”的背景图像不再存在。 Google chrome控制台出现错误“无法加载资源:服务器响应状态为404(未找到)”

图片位于“ img / Header.jpg”下

检查了新的导航栏冲突代码,无法找到问题。 仔细检查文件位置

CSS



.hero-image{
    background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url("img/Header.jpg");
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
}

.hero-text{
    text-align: left;
    position: absolute;
    margin-left: 20%;
    color: white;
    font-family: 'Roboto Mono', monospace;
}

*{
    margin: 0px;
    padding: 0px;
    box-sizing: border-box;
}

nav{
    display: flex;
    justify-content: space-around;
    align-items: center;
    min-height: 8vh;
    background-color: #343434;
    font-family: 'Roboto Mono', monospace;
}

#logo{
height: 100px;
}

.nav-links{
    display: flex;
    justify-content: space-around;
    width: 30%;
}
.nav-links li{
    list-style: none;
}
.nav-links a{
    color: white;
    text-decoration: none;
    letter-spacing: 3px;
    font-weight: bold;
}

.burger{
    display: none;
    cursor: pointer;
}

.burger div{
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 5px;
    transition: all 0.3s ease;
}


@media screen and (max-width: 1024px){
    .nav-links{
        width: 60%;
    }
}

@media screen and (max-width: 768px){
    body{
        overflow-x: hidden; 
    }
    .nav-links{
        position: absolute;
        right: 0px;
        height: 100vh;
        top: 0vh;
        background-color: #3f3f3f;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 80%;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.5s ease-in;
    }
    .nav-links li{
        opacity: 0;
    }
    .burger{
        display: block;
    }
}

.nav-active{
    transform: translateX(0%);
}

@keyframes navLinkFade{
    from{
        opacity: 0;
        transform: translateX(50px);
    }
    to{
        opacity: 1;
        transform: translateX(0px);
    }
}

.toggle .line1{
    transform: rotate(-45deg) translate(-5px,6px);
}
.toggle .line2{
    opacity: 0;
}
.toggle .line3{
    transform: rotate(+45deg) translate(-5px,-6px);
}

HTML

        <div class="hero-text">
        <h1>Ruan Kuypers</h1>
        <h2>Websites. Done. Right.</h2>
        <h3>A relighable business partner.</h3>
        </div>
    </div>

无法加载资源:服务器的响应状态为404(未找到)

1 个答案:

答案 0 :(得分:0)

这取决于您的文件夹结构外观以及HTML在目录或根文件夹中的位置。

如果它是根文件夹,请尝试:"./img/Header.jpg"或在文件夹外部请尝试"../img/Header.jpg"