• Home
  • Photo Gallery
Renaissance Man
Jack of all trades, Master of none
  • Categories

    • Art (1)
    • Differences US vs PL (4)
    • Dreams (2)
    • Gaming (3)
    • Gluten Free Recipes (5)
    • Graphic Design (1)
    • Life (36)
    • Movies (2)
    • Poetry (1)
    • Poland (27)
    • Short Stories (3)
    • Sleep Experiment (15)
    • Travel (6)
    • Uncategorized (6)
    • Web Design (3)
    • Writing (2)
  • Random Image

    oasis
  • Calendar

    November 2008
    S M T W T F S
    « Oct   Dec »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
  • Blog Links

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Photo Gallery

    Expand all | Collapse all


Nov 25

Using Two Background Images (CSS)

Web Design Add comments

I came upon a situation today where I had two different images I wanted to use for my background.

The first was a gradient, with a grid-line pattern overlayed.  Normally I would  just make the background color match the ending color of the gradient and problem solved.  But in this case I have the gridlines suddenly stopping on long pages.

I could have just made an extremely "tall" image, but that would be unreasonable and inflexible, since page height has no limit.

Instead, what I wanted to do is have another image that I could tile which has the same pattern as the gradient background, but was just a solid color, matching the end of the gradient.

To solve this problem, I set the background of the HTML element to be the solid-colored image and set the background of the BODY element to be the gradient.  Be sure to leave the background color of the BODY blank, or it will cover the HTML background.

Here is the code:

html
{
    background: #003366 url('background2.gif') repeat;
}

body
{
    background-image:    url('background1.jpg');
    background-position: top left;
    background-repeat:   repeat-x;
}

Leave a Reply

You must be logged in to post a comment.

Powered by WordPress .::. Designed by SiteGround Web Hosting

cssandhtml