The background images appear to be functioning correctly on VS Live Server, but for some reason they are not displaying

Recently, I encountered an issue where the picture I wanted to display was not showing up in Chrome, although it was visible when using VS Live Server. Another problem arose when I used "/"; it worked with VS Live Server but caused the background to not display in other browsers. Can someone help me solve this dilemma?

Below is the code snippet:

html:

     <nav id="navbar" class="navbar">
        <ul>
          <li><a class="nav-link scrollto active" href="#hero">Home</a></li>
          <li><a class="nav-link scrollto" href="#about">About</a></li>
          <li><a class="nav-link scrollto" href="#services">Services</a></li>
          <li><a class="nav-link scrollto" href="#contact">Contact</a></li>
          <li><a class="getstarted scrollto" href="indexAR.html">العربيه</a></li>
        </ul>
        <i class="bi bi-list mobile-nav-toggle"></i>
      </nav><!-- .navbar -->

    </div>
  </header><!-- End Header -->

  <!-- ======= Hero Section ======= -->
  <section id="hero">
    <div class="hero-container" data-aos="fade-up" data-aos-delay="150">
      <h1>Plan. Launch. Grow.</h1>
      <h2>We hope to create a world where our descendants can enjoy a sustainable future</h2>
      <div class="d-flex">
        <a href="#about" class="btn-get-started scrollto">Get Started</a>
      </div>
    </div>
  </section><!-- End Hero --> 

css:

#hero {
  width: 100%;
  height: 100vh;
  background: url("/assets/img/5secondhome_lon_ii_sca_8820.png") top center;
  background-size: cover;
  position: relative;
  padding: 0;
}

Answer №1

I suspect the issue is stemming from the <link> tag.

If you have a <link> element with an attribute of src that starts with a period . before the relative slash like so:

<link rel="stylesheet" href="./css/style.css">

Try fixing this by removing the period .

<link rel="stylesheet" href="/css/style.css">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to cycle through sets of listed data in isolation from one another

Does anyone know how I can create a simple toggle for 3 list groups? I want each group to only have 1 active item at a time, totaling 3 active items (one per group). I've tried some code, but it's only deactivating the active class on the last l ...

Is it possible to dynamically include a span element rather than using a Label control in the code?

Is there a way to programmatically add a span tag in the code-behind? If so, is there an equivalent HtmlControl that can be used? Currently, I am following this method where I am constructing rows for a table within an Itemplate implementation. var header ...

Enhance the appearance of the standard black rectangle displaying the messages "No video source" or "No video permissions"

Is there a way to change the styling of the video element that appears as a black rectangle with a strikethrough play button when the user is prompted for permission on Safari? Does it have a specific ID, class, or tag that can be targeted? I'm curre ...

Ion-row appears out of frame

This is a simple layout: <ion-content> <ion-grid *ngIf="loaded"> <ion-row> <ion-col>Stuff</ion-col> <ion-col>Stuff</ion-col> <ion-col>Stuff</ion-col> </ion-row> < ...

What is the best way to place focus following text?

<script> function setupTextarea(){ var textBox = document.getElementById('q'); textBox.focus(); textBox.value = textBox.value; } </script> <body onload="setupTextarea();"> <textarea name='q' rows='3' col ...

transferring information from a JavaScript variable to an EJS variable

I am currently storing a value in the 'items' variable within a script tag in an HTML document. However, I now need to pass this data from 'items' to the back end in order to store it in a database. I attempted to make 'selectedTea ...

Exploring the Power of Merging HTML with JavaScript in Shopify

Here is a snippet of code that I am grappling with: <div id="next-shipment"></div> var date = new Date(); // today using client's timezone date.setDate(date.getDate() + 1); // move to tomorrow date.setUTCHours(11,0,0,0); // set time using ...

Navigating a collection of objects after a button is clicked

My current library project involves looping through an array of objects to display them on a grid based on input values. Here is the code snippet for my loop: const addBook = (ev) => { ev.preventDefault(); let myLibrary = []; let bookIn ...

Guide on showcasing active users currently online within the system utilizing CodeIgniter

I'm currently working with CodeIgniter and trying to display live online users using this framework. I attempted some code, but I'm feeling a bit lost now. I found a helpful video that I learned from: Alternatively, I followed these steps as sh ...

Transform a hexadecimal string into a hexadecimal color representation within SCSS

I have a plethora of colors stored in JSON format. I am utilizing rootbeer with gulp to convert them into Sass maps for processing by SCSS: { "blue": "33A2FF" } into $colors: ( "blue": "33A2FF" ); I am able to use ...

CSS gradient in a vertical orientation

I am attempting to create a vertically animated linear-gradient, but for some reason it only works when I use pixel values instead of percentages for the background-position in keyframes. Using a percentage would be more flexible since the dimensions of th ...

Automate the process of filling up and activating a bootstrap dropdown upon a click, and clearing it out when it is

Is there a method to reveal the dropdown content only upon clicking instead of displaying all content at once and increasing the lines of HTML code? Perhaps using an onclick attribute on the button and incorporating a function inside? var data = [{ " ...

The counter variable does not function properly within a setInterval function

I have encountered an issue with my scroll-counter variable inside the setInterval function. It increments by 1 each time the setInterval function runs, which is supposed to happen 20 times before stopping. However, I noticed that the value of this variabl ...

Trouble displaying background image in Electron Application

When I try to load an image file in the same directory as my login.vue component (where the following code is located), it won't display: <div background="benjamin-child-17946.jpg" class="login" style="height:100%;"> A 404 error is popping up: ...

javascript issue with showing content on click

I'm currently working on a school assignment where I am using the onclick() function to display information about an object. However, I am facing an issue where the information is not popping up as expected. HTML <!DOCTYPE html> <html> ...

"Idle Encasement" resulting in an abundance of empty room

I am currently working on building a website (as a beginner) and encountering an issue where the footer section is abnormally longer on one specific page compared to others. It's puzzling because the same code works perfectly fine on other pages but s ...

Press the "show additional content" button on the nytimes.com website using selenium

I'm experiencing difficulty scrolling through this webpage. Once I reach the bottom of the page, I am unable to locate and click on the "SHOW MORE" button using selenium. self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") ...

The clear function in the template slot of Vue multiselect is not functioning properly

I decided to incorporate the asynchronous select feature found in the documentation for my project. This feature allows me to easily remove a selected value by clicking on 'X'. Below is a snippet of the general component that I use across variou ...

javascriptif the number is a whole number and evenly divisible

I am currently developing a script that tracks the distance traveled by some dogs in meters. It is basically just a gif running in a loop. What I want to achieve now is to display an image every 50 meters for a duration of 3 seconds. Here's my attempt ...

Stylishly Select with Bootstrap 4

Currently, I am utilizing Angular 2 with bootstrap 4 and have implemented the following select element: <div class="form-group"> <label class="col-md-4 control-label" for="OptionExample">Choose an option:</label> <div class="c ...