1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to fix the background image to the wrapper?

Discussion in 'CSS' started by ruseneca90, Aug 7, 2014.

  1. #1
    Hi,

    I have a problem with the design of a wallpaper which is for advertising. I would like to set the banner to fit the wrapper and apply some padding. For example 140px left and 140px right.
    The problem is that every time I check the website with different resolution, the background image floats to the left. I would like to float with the wrapper, according to the resolution of the viewers.

    Here's what I have:

    For wrapper:

    position: relative;
    width: 920px;
    margin: 0 auto;
    margin-left: 0 auto;
    margin-right: 0 auto;
    padding: 0;
    border-top: 1px solid #dadada;
    background: none repeat scroll 0 0 #FFFFFF;
    box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2);

    For the branding:

    z-index: 0;
    background: no-repeat scroll center top 0px transparent;
    position: fixed;
    padding-left: 56px;
    margin: auto;


    How to fix the branding banner ( wallpaper ) to the wrapper and when wrapper moves, the branding banner moves with the wrapper?

    Here's a demo of what I'm going to create: AdOcean Demo http://demo.adocean-global.com/main.php?x=BI&y=Background%20Image
    Thanks.
     
    Solved! View solution.
    Last edited: Aug 7, 2014
    ruseneca90, Aug 7, 2014 IP
  2. #2
    The background image has nothing to do with resolution, container size or anything else in the normal flow, it is is just decoration. If you want it to be responsive then you need to use media queries or scripting. Or do a mor logical design where the image is a component of the design instead of just passive decoration that you want to stick things on.
     
    COBOLdinosaur, Aug 9, 2014 IP
  3. ruseneca90

    ruseneca90 Active Member

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I solved the problem by using a different <div> and centering it, then coding the .css file with the W and H at 100%. Position is set to absolute. Now, it works.
     
    ruseneca90, Aug 10, 2014 IP