Grow your CSS skills. Land your dream job.

Background Image dimensions

  • # January 1, 2010 at 1:55 pm

    Hi everyone and hopefully a happy new year to you all. I have a nagging infuriating problem that I can not resolve. I have not found a single book or web reference that addresses this issue so I am posting it here. Hope someone can clear up weeks of hair pulling.

    I want to place a background image (created in PS CS3) into the Body element. Now, I tried chris’s code where a background image will resize automatically to fit different users’ web browsers but this did not work for me (I will try solving that issue another time). What I really need to understand is what measurements to use as a rule of thumb for a background image, how to set its width and height correctly either in photoshop or in the css itself, whichever is preferrable.

    For eample if I have background-image: { url(images/pppp.png) width: 100%} does not work. All I need to understand is how best to set background images so that they fit the majority of screens without scroll bars, or will stretch a little bit to acommodate slightly larger browsers.

    I really have found no references for HOW to properly deal with this issue in any book that I have sourced both in my library and in book shops where I sometimes sneak in to read. Everyone deals with the code but not with the practical issue of placing. Yes by the way I am new to css, about three months into it, everything goes fine, but this one issue has me in turmoil. Even on the web I have not been able to find anything that addresses the situation of HOW exactly one best deals with placing backgound images for suitability for the majority of browser windows.

    Thankyou.
    Chris

    # January 1, 2010 at 2:05 pm

    Have a look at this website: http://960.gs/
    I hope that helps.

    # January 2, 2010 at 5:22 am

    Thankyou for your help. Unfortunately this site totally confuses me as to its purpose, simply don’t get it. Besides, it does not address the issue of background images filling the browser without scroll bars and being flexible etc. But thanks for the offer.

    # January 2, 2010 at 5:43 am

    There really isn’t a rule of thumb for your issue. It’s all personal preference.

    Users all have different sizes that they prefer while browsing. It used to be that everybody designed for 800px, now it’s 960. But some people browse bigger than that. There is no set size.

    However, you could:

    a) create a background gradient that you repeat vertically or horizontally

    b) create a HUGE background image (1200+ and aligned to the left) with overflow set to hidden.

    c) create a fixed width content area (960px) that has your background image and then have a solid color/other image/gradient for the body.

    # January 2, 2010 at 5:50 am
    Quote:
    for eample if I have background-image: { url(images/pppp.png) width: 100%} does not work. All I need to understand is how best to set background images so that they fit the majority of screens without scroll bars

    Oh ok, I don’t think I understood you before. The css code for that is:

    Code:
    body {background: #fff url(images/pppp.png) repeat-x left top}

    That will make the image repeat horizontally regardless of how large the monitor is. Is that what you were asking?

    # January 2, 2010 at 8:11 am

    Maybe better solution is to create new tag for this, for example:

    Code:


    This solution might be flatten (height isn’t correctly calculate) but I think this is some way to go.

    # January 2, 2010 at 1:45 pm

    Ok, thankyou, I will try a few suggestions here, and will get back to you each one who has answered. Give me a few hours, thanks.

    # January 2, 2010 at 2:18 pm

    Hi, guys, well I’m back. I tried very briefly a couple of your suggestions, but it was getting me no where. Though i will try these things out on a fresh document soon. It’s just that I am dealing with transparency as well and have had to set one layer of my image in the html element and the other in the body element otherwise I will not get the transparent effect.

    thankyou for your suggestions, I have at least copied your answers over to my machine for future reference.

    # January 4, 2010 at 4:22 am

    I wonder why these answers haven’t solved your problem yet.I think your question needs some expert advices.

    # January 4, 2010 at 5:34 pm

    I am going to try them out soon, things a little complicated at the moment. Need to solve another issue first. Happy new year.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".