The background image suddenly halted its loading process

Currently, I am using a CDN to incorporate Bootstrap into a school project. I have added code to load a background image and stretch it across the page. Strangely, the image loading function has suddenly stopped working. Previously, it was able to load the image without any issues, but now, it doesn't seem to work. Upon inspecting the page in Chrome's developer view under the "Sources" tab, I noticed that the image does not even appear there. The image file is located at the same directory level as my index.html file. This sudden change is puzzling as the background image used to load perfectly before this glitch occurred. I've attempted various troubleshooting steps such as pointing to a different image, hard reloading the page, and clearing the cache in developer mode, yet none of these actions have resolved the issue. In essence, no background images are being loaded anymore.

<style> 
        body {
          background: url('bkgrnd3.jpg') no-repeat center center fixed;
          -webkit-background-size: cover;
          -moz-background-size: cover;
          background-size: cover;
          -o-background-size: cover;
        }
    </style>  
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Grainy Travel: Plan Your Escape with 100% Humans!<\/title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
        <style>
        .fakeimg {
        height: 200px;
        background: #aaa;
        }
        </style>
        
         <!--custom style for background images-->
        <style>
            body {
                background: url('https://www.w3schools.com/images/picture.jpg') no-repeat center center fixed;
                -webkit-background-size: cover;
                -moz-background-size: cover;
                background-size: cover;
                -o-background-size: cover;
            }
        </style>

        <script>
            var travelImages = ["photos/DenmarkCopenhagen.jpg","photos/EiffeltopParis.jpg","photos/GoldenGateBridge.jpg"];
            var descs = ["Visit a City With Fish!", "Go to the Top of the Eifel Top!", "Check out a Red Bridge Across the Water!"];
            
            var urls = ["https://www.visitcopenhagen.com/", "https://www.toureiffel.paris/en", "https://www.goldengate.org/"];
            function displayImage(index)
            {
                var img = document.getElementById("myImage");
                img.src = travelImages[index];
            }
            
            function openWindow(url)
            {
                var win = open(url, "", "height=200,width=300,top=100,left=100,menubar=no");
                var timer = setTimeout(function(){
                    win.close();
                }, 3000);
            }
        </script>
        <style>
            .navbar-custom {
                background-color: #20c997;
            }
        </style>        

    </head>
    <body>
     <!--New Bootstrapped Navbar-->
    <nav class="navbar navbar-expand-sm navbar-custom navbar-light sticky-top">
      <a class="navbar-brand" href="index.html"><img src="Home.png" alt="logo" style="width:30px;">Home</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="collapsibleNavbar">
        <ul class="navbar-nav">
          <li class="nav-item">
            <a class="nav-link" href="contacts.html">Agent Information</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="register.html">Customer Registration</a>
          </li>    
        </ul>
      </div>  
    </nav>

        <div class="jumbotron text-center" style="margin-bottom:0">
            <h1>Welcome to Grainy Travel</h1>
        </div>
        <article>
                <!--These containers create a table from arrays of images, descriptions, and links. Onclicks open links while onmouseovers display an image below the table.-->
                <div class="container"><table class="table table-dark">
                
                    <script>
                        for(var i=0; i < descs.length; i++)
                        {
                            document.write("<tr>");
                            var myString = "<td class=\"col-sm-6\"><img src='" + travelImages[i] + "' onclick='openWindow(\"" + urls[i] + "\")' /></td><td class=\"col-sm-6\">" + descs[i] + "</td>";
                            console.log(myString);
                            document.write(myString);
                            document.write("</tr>");
                        }
                    </script>
                </table></div>
                <div class="container">
                    <table class="table table-dark">
                    
                        <script>
                            for(var i=0; i < descs.length; i++)
                            {
                                document.write("<tr>");
                                var myString = "<td class=\"col-sm-6\" onmouseover='displayImage(" + i + "); '>" + descs[i] + "</td>";
                                console.log(myString);
                                document.write(myString);
                            }
                        </script>
                        <td class="col-sm-6" ><img id="myImage"/>
                        </td>
                        </tr>
                        </table>
                </div>
                    
                
        </article>
    <div class="footer">
            Copyright 2021 &amp;copy;
        </div>
        
    </body>
</html>

Answer №1

Switch up the image location or experiment with a different image option it could make a difference

Answer №2

I believe the issue lies in the image's file path. In the provided jsfiddle example, I have included the complete URL for an image source from the internet. You can attempt to use the full path within the css by adjusting the background: url('bkgrnd3.jpg') statement to reference the image bkgrnd3.jpg. As mentioned, the image may not display properly due to incorrect sourcing.

body {
  background-image: url("https://www.w3schools.com/images/picture.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
}
<body>

</body>

Answer №3

Just wanted to share an update for those who may come across a similar issue. I recently encountered a problem where the interpreter was only recognizing styles from the second set of blocks, causing the edits in the first set to be ignored. By transferring the body class modifications to the second block specifically dedicated to navbar customization, the error was resolved. Big thanks to everyone who offered their assistance!

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

Dynamically selecting themes in an Angular application based on user input

Experimenting with an angular project where users can choose themes from a dropdown menu to modify the appearance of the application using this handy tutorial Utilizing :host-context for this purpose Encountering an issue where the selected themes are no ...

Online platform showcasing erroneous information about Bootstrap Screen Readers

I'm currently developing a new website by utilizing some code I previously wrote for an older site. However, the incorporation of slightly more advanced PHP includes seems to have resulted in different behavior on the two sites. Both sites feature a ...

Is there a way to check if a row already exists in a MySQL database using the time function in a PHP MySQL query?

In my current project module, I am developing a feature that allows faculty members to post attendance for students by selecting from a dynamically generated dropdown menu based on information provided by the faculty. When the faculty selects a specific ye ...

Tips for relocating anchor elements to less desirable locations

My website has an issue with anchor elements appearing too frequently and not in the desired location. I need someone to help fix this so there are only two anchors displayed. After checking my code, it seems like there are not more than the specified num ...

Utilizing CSS to dynamically update SVG icons within the navigation menu upon tab selection

Feeling frustrated and in need of assistance with my current issue. I am attempting to make a change - when I click on a tab in the menu, the default black SVG icon should be replaced by a white one. #menu a .main-menu-icon { display:inline-block; width:2 ...

Automatically populate Edit Form fields with selected table values

My goal is to develop an Edit feature that enables users to scroll through a table and click a button in each row to modify the data within a modal window. The challenge I am currently facing involves prepopulating the form with existing values. How can I ...

Having trouble getting Sass extending to work in a basic scenario?

Here we have a simple example of Sass code, an Angular 2 component that accesses the Sass code, and the rendered HTML. However, there seems to be an issue with the blueBig span element in the last part. As someone new to Sass, I am not sure why this basic ...

Centered inline-block divisions

I've been coding for a number of years now, but I've recently started learning CSS. I'm currently facing an issue and need some help. I want to place two divs next to each other and center them. Here's the code I'm using: HTML: & ...

What is the best way to align a dropdown menu vertically?

Is there a way to center the text vertically alongside the drop-down list so that they are on the same level? <p> <span>Hello World</span><select><option>Hello</option></select> </p> span { font-size: 5 ...

"Challenges encountered while trying to format a table responsively with Bootstrap CSS

My objective is to display two tables side by side, with the right table overflowing horizontally. However, I am currently facing an issue where the second table is being pushed below the first one. Any assistance on resolving this problem would be highly ...

show: alongside move: towards the left

Reviewing some vintage CSS code from 2008, I stumbled upon the following CSS snippet for a menu/navigation: #menu li { display: inline; } #menu a { display: block; float: left; height: 32px; margin: 0; padding: 18px 30px 0 30px; ...

Display the div with the specific id when it is clicked using jQuery

How can I make one div appear when another div is clicked? Specifically, I want #musicinfo to appear when #music is clicked. Below is the CSS styling for these elements: #music { float:left; height:25px; margin-left:25px; margin-top:25px ...

Error when the class is not found + Application

I am attempting to create my debut Applet named MemoSaver2.java In addition, I have crafted the following html: <html> <object classid="java:MemoSaver2.class" type="application/x-java-applet" archive="MemoSaver2.jar" he ...

Create a navigation link in Vue-bootstrap that directs to an 'external program'

After deciding to use vue-bootstrap instead of just bootstrap for its additional features like tabs, I made the choice to rewrite the navigation using it as well. However, I encountered an issue where the links in the navigation menu are pointing to the co ...

Implementing a horizontal card layout using a for loop in a Flask application

Currently, I have implemented a for loop to showcase a list of cars in a card layout. However, upon integrating the jinja template, the cards now appear vertically instead of horizontally. Below is the HTML code snippet: {% for car in cars %} < ...

What could be causing the side margins on my navbar in mobile view in Bootstrap?

After spending some time working on a simple navbar with CSS styling, I encountered an issue when viewing it in mobile mode. The navbar did not expand to 100% of the screen width and had a margin of about 20px on both sides. CSS .navbar .brand { wi ...

What is the method for retaining the email and password when the browser is refreshed in my "keep me logged in" feature?

Is there a way to make the email and password stay in the modal dialog login page even after refreshing the same page? Specifically, I want the email and password fields to still contain the information I entered if I check the checkbox for "keep me logged ...

What is the method for creating an HTML table with a percentage-based width?

Is it possible to create a 4-column table with each column taking up 100% of the width? The idea is to have two cells in each column - one (cell A) occupying 15% of the width and the other cell (cell B) taking up the remaining space. However, there seems ...

Tips on identifying when the user is silent and automatically play the following audio file using Html5 and Javascript

My goal is to create a project similar to AI using an array of audio files. I am utilizing the annyang API for voice commands to initiate the program. Once the first audio file finishes playing, the program pauses and waits for me to speak. If there is no ...

Styling <Link> component with styled-components: A step-by-step guide

Utilizing the Link component from @material-ui/core/Link in my TypeScript code was initially successful: <Link href="#" variant="body2"> Forgot? </Link> However, I am exploring the transition to styled-components located in a separate file. ...