0

I'm setting up a responsive website and after adding the responsive navigation the background image assigned to the div ".hero-image" is no longer there. Google chrome console is giving a error "Failed to load resource: the server responded with a status of 404 (Not Found)"

The image is located under "img/Header.jpg"

Checked my new navigation bar conflicting code, unable to find the problem. Double checked the file location

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>

Failed to load resource: the server responded with a status of 404 (Not Found)

Vexagon
  • 23
  • 5

1 Answers1

0

It depends on how your folder structure looks as well as where your HTML located in a directory or root folder.

If it is the root folder try: "./img/Header.jpg" or outside a folder try "../img/Header.jpg".

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Galanthus
  • 1,958
  • 3
  • 14
  • 35
  • 1
    Hello, sorry for the late reply, I've tried that and it still doesn't work. I have one folder named img which has the picture "Header.jpg" and the rest are in the root folder named ("index.html, style.css, app.js") – Vexagon Jul 12 '19 at 13:54
  • @Vexagon no problem! Are you using a web browser like Mamp? – Galanthus Jul 12 '19 at 15:15
  • @Vexagon "/img/Header.jpg" try another image add it to image see if that works. – Galanthus Jul 12 '19 at 15:21
  • 1
    Thank you for your time, I managed to find the problem, the div classification in the css was set to absolute. Changed it to relative and it appeared. ;) – Vexagon Jul 12 '19 at 15:35