Grow your CSS skills. Land your dream job.

[Solved] Making a Liquid banner

  • # March 23, 2010 at 2:07 pm

    Ok so I am going to do my best to ask this question.

    Basically I need to make a banner that is liquid (liquid width). It needs to be able to stretch/open up when the browser is resized. I want to make the banner image and put it in a div (I’m assuming, or something) and when the browser is resized the div widens or shortens (height staying the same) and all it would be doing is revealing more of the banner image’s background evenly on both sides. THere will be a main message graphic area in the middle that needs to stay centered. I am hoping this can be done with just 1 image. Does that make sense?

    The 1st time I did it I really restricted myself and I did the main center image and a repeating background that lined up perfectly with in in the BG. I dont want to be restricted to having to have a repeat bg.

    Can anyone show me how to do this or give me an example of where this is done?

    # March 23, 2010 at 2:32 pm

    You can have a div centered with margin: 0 auto, with the image centered as well inside that. Set the height of the div to the height of your div. And for the width, set it as a percentage. That way, as the browser stretches, the div stretches, and as the browser shrinks, the div shrinks.

    # March 23, 2010 at 2:38 pm

    woudl the image be applied in the CSS or in the HTML?

    # March 23, 2010 at 2:44 pm

    You can put it as a background image in the CSS

    # March 23, 2010 at 3:48 pm

    That worked. Thanks alot!

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

You must be logged in to reply to this topic.

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