CSS Tip of the Weekend

For those who care, I learned a valuable bit of CSS glory from a competing media firm under my own roof. Thanks, Fowler!

When working with background images and colors within a DIV, you may want to have a DIV contain a background image that does not repeat, and then a background color to the remaining area where content overflows the image area. I had always had some issues doing this, so Fowler clarified it all for me. There are two ways you can do it properly, and then an incorrect way (which I had been using.)

Proper Way #1

background: #fff url(img/myimage.jpg);

Proper Way #2

background-color: #fff;
background-image: url(image.jpg);

Improper Way

background-color: #fff;
background: url(image.jpg);

Comments

Popular posts from this blog

Post-Run Tip of the Day

Web Development Tip of the Day