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 351637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:39:44+00:00 2026-05-12T11:39:44+00:00

Is it possible to set the size of the background image with CSS? I

  • 0

Is it possible to set the size of the background image with CSS?

I want to do something like:

background: url('bg.gif') top repeat-y;
background-size: 490px;

But it seems it’s totally wrong to do it like that…

  • 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-12T11:39:44+00:00Added an answer on May 12, 2026 at 11:39 am

    CSS2

    If you need to make the image bigger, you must edit the image itself in an image editor.

    If you use the img tag, you can change the size, but that would not give you the desired result if you need the image to be background for some other content (and it will not repeat itself like you seems to want)…

    CSS3 unleash the powers

    This is possible to do in CSS3 with background-size.

    All modern browsers support this, so unless you need to support old browsers, this is the way to do it.
    Supported browsers:

    Mozilla Firefox 4.0+ (Gecko 2.0+), Microsoft Internet Explorer 9.0+, Opera 10.0+, Safari 4.1+ (webkit 532) and Chrome 3.0+.

    .stretch{
    /* Will stretch to specified width/height */
      background-size: 200px 150px;
    }
    .stretch-content{
    /* Will stretch to width/height of element */
      background-size: 100% 100%;
    }
    
    .resize-width{
    /* width: 150px, height: auto to retain aspect ratio */
      background-size: 150px Auto;
    }
    .resize-height{
    /* height: 150px, width: auto to retain aspect ratio */
      background-size: Auto 150px;
    }
    .resize-fill-and-clip{ 
      /* Resize to fill and retain aspect ratio.
         Will cause clipping if aspect ratio of box is different from image. */ 
      background-size: cover;
    }
    .resize-best-fit{
    /* Resize to best fit and retain aspect ratio.
       Will cause gap if aspect ratio of box is different from image. */ 
      background-size: contain;
    }
    

    In particular, I like the cover and contain values that gives us new power of control that we didn’t have before.

    Round

    You can also use background-size: round that have a meaning in combination with repeat:

    .resize-best-fit-in-repeat{
    /* Resize to best fit in a whole number of times in x-direction */ 
      background-size: round auto; /* Height: auto is to keep aspect ratio */
      background-repeat: repeat;
    }
    

    This will adjust the image width so it fits a whole number of times in the background positioning area.


    Additional note
    If the size you need is static pixel size, it is still smart to physically resize the actual image. This is both to improve quality of the resize (given that your image software does a better job than the browsers), and to save bandwidth if the original image is larger than what to display.

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

Sidebar

Related Questions

I would like to know if it's possible to set an image as background
I want a background image that automatically fits the div size. I have several
I'm new to css, I have a top nav but I couldn't set its
I would like to know if it's possible to set the size of VARCHAR
Is possible to set an image as an iPhone application unique icon in code
i have a div element, with very big size background image. so, is it
Possible Duplicate: How to Set Opacity (Alpha) for View in Android i want to
Is it possible to set a larger buffer size with mediaelement.js? The idea would
Is it possible to set in the XML layout file the size of the
I have this set of html and css. What I want is to have

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.