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 float banner in foreground of div background?

Discussion in 'CSS' started by dcristo, May 9, 2006.

  1. #1
    I am having issues trying to right align banner ads in the foreground of a <div> background image which has a fixed width of 760 px. Because the banner is too large it is just shifting the div contents below the banner and not floating at all.

    Is there any solution for this?

    I am using the code:

    <div id="logostrip"><div style="float: right">IMAGE CODE HERE</div><div style="background: url(images/cyclic/misc/logostrip.gif) no-repeat;width: 760px;height: 125px;float: left"></div></div>
    Code (markup):
    It works ok with 468x68 banners on bigger resolutions, but 1024x768 and lower the div breaks.
     
    dcristo, May 9, 2006 IP
  2. bullfrog

    bullfrog Guest

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm assuming what you are trying to do is right align and if the image is large it overlaps the background image. If that is the case the what you will want to do is remove the "float: left" from the div with the background so your code would look like...

    <div id="logostrip"><div style="float: right">IMAGE CODE HERE</div><div style="background: url(images/cyclic/misc/logostrip.gif) no-repeat;width: 760px;height: 125px;"></div></div>
    Code (markup):
    If you are looking at possibly enlarging then you may want to look at the overflow property in css.
     
    bullfrog, May 9, 2006 IP
  3. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #3
    That's exactly what I wanna do. I had already tried your code suggestion however the div is still breaking on me.

    What is overflow all about, is there a page you can point me to regarding it?
     
    dcristo, May 9, 2006 IP
  4. bullfrog

    bullfrog Guest

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    bullfrog, May 9, 2006 IP
  5. bullfrog

    bullfrog Guest

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I tested the code that I mentioned previously using firefox and IE using xhtml 1.0 strict for the doctype. Do you have the full html so I can see how it is rendering?
     
    bullfrog, May 9, 2006 IP
  6. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #6
    Oh right, so instead of breaking the div it allows you to scroll left/right.

    Not really what Im wanting to do, thanks all the same though.
     
    dcristo, May 9, 2006 IP
  7. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #7
    Sure I will PM you the details.
     
    dcristo, May 9, 2006 IP
  8. bullfrog

    bullfrog Guest

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I was able to reproduce your problem and came up with a solution. I'm going to play around a bit using the floats tomorrow but in the meantime here is a fix to your problem using a few other css properties (position, float and right).

    <div id="logostrip"><div style="position: absolute;right: 0px;">IMAGE CODE HERE</div><div style="background: url(images/cyclic/misc/logostrip.gif) no-repeat;width: 760px;height: 125px;float: left;"></div></div>
    Code (markup):
    Hope this helps.
     
    bullfrog, May 10, 2006 IP
    dcristo likes this.
  9. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,199
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #9
    Thanks for looking into it for me bullfrog, it worked great! :)
     
    dcristo, May 10, 2006 IP