The background image fails to fill the entire page

I am facing a strange issue with a website. The background image does not cover the entire page, leaving large white sections when I resize the window. Oddly enough, this problem only occurs on certain PCs or laptops. After asking several friends to test the website, they reported that they did not experience any issues with the image scaling and it always covered the entire page when resizing the window.

Here is how it appears for me: https://gyazo.com/04a679edfb7a442d09d6e7ce8b196cf9. Feel free to visit the website yourself and see if you encounter the same problem.

I am hopeful someone can help shed some light on what might be causing this odd behavior. Also, the picture seems to be zooming in/out rather than maintaining its aspect ratio when I resize the window.

https://jsfiddle.net/dn3553pg/1/

HTML

<!doctype html>
        <html>
        <head>
        <meta charset="utf-8">
        <title>onepageskiw</title>
        <link href="styles.css" rel="stylesheet" type="text/css">
        <script src="js.js"></script>
        </head>
        <body>

        <div id="forsidediv">
        <img id="forsidepic" src="baggrund.jpg">
        <nav>
            <ul id="menu">
                <li><a href="#">Top</a></li>
                <li><a href="#">Om Eventet</a></li>
                <li><a href="#">Lokation</a></li>
                <li><a href="#">Kontakt</a></li>
            </ul>
        </nav>
        </div>

        ...

    </body>
    </html>
    

CSS

@charset "utf-8";

        @import url(https://fonts.googleapis.com/css?family=Montserrat:400|Raleway:100,400|);

        body {
            margin:0;
        }

        #forsidediv {
            position:fixed;
            bottom:0;
        }

        #forsidepic {
            width: 100%;
        }

        #logodiv {
            ...
        

Answer №1

To create a dynamic background effect, consider setting the image as the background and adjusting its size to cover the entire background area by using the following CSS code:

html { 
  background: url(background.jpg) no-repeat center center fixed; 
  background-size: cover;
}

Answer №2

To avoid using the img tag in your HTML, consider setting the image as a background for the "#forsidediv" or a div within your "body" tag by adding this CSS property: background-image: url("paper.gif"); Then adjust the properties to either contain or stretch the image as needed.

Answer №3

An effective approach would be to designate the image as a background and utilize the background-size property to cover the entire screen. Consider the following code snippet as an illustration:

.background-image {
    background: url('background.jpg') center center/ cover no-repeat;
}

The reason why this issue is only noticeable on specific computers is due to the fact that the image only expands to its original dimensions without further stretching. It's likely that your monitor has a larger display compared to your friend's. You can resolve this by incorporating width: 100% to allow the image to extend beyond its initial size.

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

In JavaScript, a prompt is used to request the user to input a CSS property. If the input is incorrect,

Implement a while loop that continuously prompts the user to enter a color. If the color entered matches a CSS property such as blue, red, or #000000: The background will change accordingly, but if the user enters an incorrect color, a message will be dis ...

Choose a particular form when the dropdown option is changed

I have two forms that I would like to display based on the selection from a dropdown menu. For example, if "Form1" is selected from the dropdown, then Form1 should be displayed. If "Form2" is selected, then Form2 should be displayed. Can anyone suggest h ...

Implement a JavaScript and jQuery code that alternates between fading in and fading out every two items in a

Can someone help me figure out how to create a loop that fades in and out every 2 items from an unordered list using jQuery? I've been trying to do this, but my loop only processes one item at a time. <div> <ul> <li>item1</li ...

What is the best way to integrate images into the Shopify source code?

Looking for assistance here. I've been working on my theme in vscode and added a new section that is very simple (just text and an icon). It's working perfectly fine in Shopify cli. But when I tried to implement it on my Live theme, the icons ar ...

Can you identify the programming language used in this code snippet? - {"html":"<section class="page">

I've been approached to assist with a friend's company website since the original developer seems to have disappeared. Apologies if this question is too basic for this forum, and please forgive me if I am not in the right place to ask it. The m ...

How to style a CSS list and center-align it

My website features a <ul> list with submenus structured like this: <div id="cssmenu"> <ul> <li class='active'><a href='index.html'><span>Home</span></a></li> <li class=&ap ...

Utilizing Selenium to pinpoint an HTML element through xpath

Currently, I am in the midst of deciphering a colleague's slightly chaotic HTML as I work on developing a website testing program utilizing Selenium WebDriver in Java. Progress has been made thus far (thanks to some helpful insights from SO), but I ha ...

Update the content retrieved through ajax periodically

Looking to set up a periodic update for this ajax fetch function, say every 10 seconds. I've tried a few approaches but none seem to work as expected. That's why I'm reaching out here for help. So, any idea how I can refresh the content ev ...

Tips for Positioning Ant Design Select Dropdown Anchor to the Right of the Select Component

Currently, I am utilizing Ant Design in my project and encountering an issue with a Select component. The Select is positioned to the right side of the screen and contains labels that are quite long. This causes the dropdown to overflow and a scrollbar t ...

Challenges with locating text within the innerHtml property of a VB WebBrowser Object

Using Visual Studio 2010 with Visual Basic.NET In my project, I have created a form that utilizes a WebBrowser control to load an HTML file. Users are able to search for specific words or phrases within the document, prompting me to extract the innerHtml ...

Discover the possibilities of setting the dimensions of your anchor tags using only inline-block spans

Can anyone help me understand what is happening with this small piece of HTML code? http://jsbin.com/akome5 When viewed on various browsers such as FF4, Chrome10, IE9, IE8, Opera 11, the layout of the element appears like this: Hmm, why is this happenin ...

What is the best way to ensure a table is responsive while maintaining a fixed header? This would involve the table scrolling when it reaches the maximum viewpoint, while also keeping

Can anyone help me create a responsive table with a fixed header that scrolls when it reaches the maximum viewpoint without scrolling the entire page? I've tried using box-sizing: border-box; and overflow-x:scroll; but it didn't work. Any suggest ...

A guide on activating the Bootstrap v5 Offcanvas with toggle buttons

How can I trigger the Bootstrap V5 Offcanvas using Bootstrap switches? I want the Offcanvas to open when the switch is checked and close when the Offcanvas is closed. Sample Code : <!-- Using checkbox switches to open the offcanvas --> <div class ...

The Datalist feature in HTML5 offers an auto-suggest functionality that displays a list of options beginning with the

In my project, I am utilizing HTML5 Datalist for autosuggestion. By default, HTML5 follows the keyword contains approach rather than the starts with approach. For example, if my datalist includes one, two, three and I type "o" in the search box, it displ ...

What is the best method for adding lengthy text into a mySQL database with PHP?

My current setup involves using a basic HTML form and PHP to insert strings into a MySQL Database. This method works well for shorter strings, but I've encountered issues with longer strings. Interestingly, when using phpmyadmin, I can successfully i ...

Generate a new object from the contents of a div

Having the HTML structure below: <div id="main"> <div id="myDiv1"> <ul> <li>Abc</li> <li>Def</li> </ul> </div> <div id="myDiv2"> <ul> <li>Ghi</l ...

Hovering does not activate the CSS dropdown

I have been struggling to implement a pure CSS menu that shows on hover. Although everything seems to work fine, I encounter an issue when trying to hide and then show the menu again upon hover. Here is the HTML code: <ul id="nav-menu"> <li& ...

Unable to hear sound on Mozilla Firefox

I am facing an issue with playing an audio file using the audio tag inside the body element. The audio plays perfectly in Chrome once the body has finished loading, but it fails to play in Mozilla Firefox. I even attempted to download the audio file and pl ...

Is there a way to customize the hover effect on this navigation link in Bootstrap that includes a span and an icon from Bootstrap?

<li class="nav-item mt-3"> <a href="#" class="nav-link px-2 d-flex justify-content-start align-items-center"> <i class="nav-icon bi bi-calculator-fill fs-4"></i> ...

What's the most effective method for dividing a list into columns?

I attempted to organize my list into 4 columns using Bootstrap's grid system, but it feels somewhat unconventional. Is there a more efficient method to achieve this layout? This is the approach I took: <div class="grid"> <ul cl ...