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.

Displaying two images on opposite sides

Discussion in 'HTML & Website Design' started by cre8ive, May 13, 2008.

  1. #1
    I have a rectangle stretching out from left to right. I want to display two images inside it on opposite sides. What I came up with is the following:

    <div style="background: url('images/Gulab.jpg') no-repeat #040406; height: 45px; width: 100%;">
    	<div style="background: url('images/Swaraj.jpg') right no-repeat; height: 45px; width: 100%; float: right; display: inline; text-align: right;">
    	</div>
    </div>
    
    Code (markup):
    Isn't there a better way to do this? It does what I need to do for the time being, but I definitely want to code HTML more efficiently ... and more ... cleanly.

    ( I'm using this code on this website. )
     
    cre8ive, May 13, 2008 IP
  2. chantown

    chantown Peon

    Messages:
    406
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    style float left, right.
     
    chantown, May 13, 2008 IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Because you have this:
    width: 100%; float: right;
    nothing is working except because you have set the background position of the image to "right" so you might as well get rid of "width: 100%; float: right; and display: inline; : )

    In fact, this is what you could do:

    (container somewhere obviously):
    <div>
    <div></div>
    </div>
    hopefully there's stuff in there because otherwise it's stoopid HTML : )

    div {
    background: url(firstimage.gif) 0 0 no-repeat;
    }
    div div {
    height: 45px; (cause with bg images, there's no content here to make the divs tall enough on their own...)
    background: url(secondimg.gif) 100% 0 no-repeat;
    }

    Instead of 0 0 and 100% 0 you can also use left top and right top.
     
    Stomme poes, May 14, 2008 IP