Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7091671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:12:55+00:00 2026-05-28T08:12:55+00:00

I am trying to build a website with a background image that I want

  • 0

I am trying to build a website with a background image that I want to always fill up the entire screen.

When the browser window is short and wide, I want the image to expand so that the top part of it fills up the entire screen length-wise and the rest of it is not visible.

When the browser window is tall and thin, I want the image to expand so that the left part of it fills up the entire screen height-wise and the rest of it is not visible.

Using the CSS3 background-size: cover property makes the former work like a charm, the latter does not. Instead, the background image is shrunk so that it is entirely visible within the narrow region available and scaled to the width, and then the rest of the page below it is simply the background color.

body {
    background-color: #BF6F30;
    color: black;
    font-family: Georgia, "Times New Roman", sans-serif;
    background: url(' ... ');
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

How can I fix this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:12:56+00:00Added an answer on May 28, 2026 at 8:12 am

    Are you interested in only using a CSS background image? This can be done by loading an image and constraining it with the CSS.

    Would either of these examples work?

    HTML

    <body id="page-body">
    <img class="bg" src="images/bodyBackground1.jpg">
    <div class="wrapper">
    
    
    </div>
    </body>
    

    CSS

    html {
            background: url(images/bodyBackground1.jpg) no-repeat center center fixed;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
    }
    
    body {
        background:#fff;
        margin: 0;
        padding: 0;
        overflow:hidden;
    }
    
    html, body {
        height: 100%;
    }
    
    img.bg {
            /* Set rules to fill background */
            min-height: 100%;
            min-width: 1024px;
    
            /* Set up proportionate scaling */
            width: 100%;
            height: auto;
    
            /* Set up positioning */
            position: fixed;
            top: 0;
            left: 0;
    }
    
    @media screen and (max-width: 1024px) { /* Specific to this particular image */
            img.bg {
                    left: 50%;
                    margin-left: -512px;   /* 50% */
            }
    }
    

    Or this one? This one loads images from a database into an array and loads them at random, but you might be able to glean some info from this:

    PHP load function

    <?php
        $bg_images = array(
            0 => 'comp1.png',
            1 => 'comp2.png',
            2 => 'comp3.png',
            ....
        );
        $image = $bg_images[ rand(0,(count($bg_images)-1)) ];
        $showBG = "<img class=\"source-image\" src=\"images/bg/" . $image . "\"/>";
    ?>
    

    HTML

    ...
    <body>
    <?php echo $showBG; ?>
    <div id="wrapper">
    ...
    

    CSS

    html, body {
        margin:0;
        height:100%;
    }
    
    img.source-image {
        width:100%;
        position:absolute;
        top:0;
        left:0;
        z-index:0;
        min-width:1024px;
    }
    

    These options should fill up the browser window according to the height and width.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a website that reads Icelandic texts written in a particular
Trying to build a website where the background of the site is a video
I'm trying to build a website that will allow user to upload video files
I'm trying to build a website that has a Member section, and I'm struggling
I'm trying to build a website that looks the same (or at least very
I'm trying to build a basic website, but that doesn't limit my ability to
I'm trying to build a simple Asp.Net website that will list some files. Each
I'm trying to build a website that provides a login for users. Once these
I'm trying to build a website. I have it displaying correctly in every browser
I'm trying to build a page on my personal website that both used jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.