two background images, one across top, other down side

topic posted Wed, April 12, 2006 - 3:22 AM by  Nightwind
Share/Save/Bookmark
Advertisement
Trying the changeover from tables.

Wondering if I can have a repeating image or color bar going across the top of the browser window, and another color band going down the left side.

In tables I used to have the left side be the background image for the page, and across the top be in a table with a width of 100%

Hope this is possible in CSS

Help please.
posted by:
Nightwind
Maryland
Advertisement
Advertisement
  • Well if you want to use 2 actual images ont he same element youre out of luck. Only Safari 2.0 renders it properly. Im not sure if this is a bug in Safari or a better adherance to standards.

    If you want can use a solid color and an image the prospects get a bit better. However you can then only tile the bg in one direction. For example if you want 200px of the #f00; at the left of the element then you can only tile the background on the x axis and the same for y. it would look something like this:

    div#element {
    background-color: #f00;
    background-image: url();
    background-position: 200px 0px; /* i always get these confused as to which comes first, i think its x just liek standard coords but i could be wrong... this assumes x does indeed come first */
    background-repeat: repeat-x;
    }

    Overall though i woudl just recommend using nested elements. It will save you headaches.
    • body{background:url(thesideImageTile.jpg) left repeat-y;}

      in the main page make a new div...

      <body>
      <div id="TopImage" style="background:url(theTopImage.jpg) left repeat-x;">this is the thing at the top of the page with your picture</div>
      • you should avoid seeting styles in the tag itself (try and keep elements ot as few attributes as possible) and use a linked or inlie style sheet instead like so (this is for inline):

        <!-- styles go in the HEAD of the document -->
        <style type="text/css">

        /* this uses an id selector, alternatively you could use an class or tag selector. a class selector would look like
        .TopImage { [rules] } while a tag selector would be div { rules } a tag selector will style every div according to the rules though so thats not an option here. Also what jason provided was shortand for the background properties, i prefer to break mine out long hand, although thats not necessary - i find it makes for less confusion though */

        #TopImage {
        background-image:url(theTopImage.jpg);
        background-position: left;
        background-repeat: repeat-x;
        /* by setting the height and width properties explicitly a spacer image isnt needed */
        height: 100px;
        width: 750px;
        }
        </style>

        <!-- thi markup would be in the BODY of the document as it exists now -->
        <!-- not the removal of the style attribute in favor of only an id. id you were using a clss selector you would have have class="TopImage" in order t o apply the style to the element -->
        <div id="TopImage">
        </div>

Recent topics in "CSS is not a disease!"

Topic Author Replies Last Post
Cellspacing -- ARGHHHH furtographer 4 November 19, 2008
IE6 bug...er, REQUIREMENT for Submit button furtographer 0 August 19, 2008
firebug for ie? /* j */ 2 April 3, 2008
Override Myspace vomit furtographer 10 February 11, 2008
em JAKEYERBOOTY 2 February 11, 2008