954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to color padding differently.

Hello all,

I'm trying to make a webpage that has about 200px padding on the left and right side and 0 padding at the top and bottom, i would like my content to be viewed in that small area. I'm wanting the background color where my content will be to be grey but i want the padded sides to stay white. Is this possible?

Like this http://www.cssbasics.com/ , you see how the sides are grey and the content area is in a different color, how can i do this?


Thank you!

Frensi
Newbie Poster
9 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Use two divs, one inside the other.

give the outer div a background color.
give the inner one a different color.
give them both a width, and make that of the inner one smaller by the sum of the left and right "padding".
(eg outer width=800px, inner = 600px)
Set the margin-left and margin-right of the inner one to the "padding". (ie margin:whatever 100px; where whatever is top and bottom)

Learn CSS.

drjohn
Posting Pro in Training
445 posts since Mar 2010
Reputation Points: 76
Solved Threads: 80
 

"Learn CSS."

Crall back under your bridge, the guy was just asking if there was a better way. I was wondering myself, being new to CSS. You're not a genius, I had worked out your suggestion as the OP probably did, but he wanted confirmation. Cretin.

flubberdub
Newbie Poster
1 post since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Thanks for your kind words.
Such a nice introductory post from a new member.

My answer to the above thread, about 15 weeks ago, was correct.

Encouraging someone to learn css is always good advice. www.cssbasics,com is one of the sites I often recommend to people seeking to learn about css, so it was nice to see that the original poster had been there. They've had a face lift to their own css. They set the body background to one colour, and the main div background to a different colour, but that would not be the correct solution for the original poster's question, of course, for the obvious reasons.

Oh, and yes with an IQ measured at 154, I don't need to worry about your opinion on my intellect. And you spelt crawl wrongly. ;)

But if you have any problems, do just ask for help, and I'll see if I can find a solution for you. Or give help, of course.

drjohn
Posting Pro in Training
445 posts since Mar 2010
Reputation Points: 76
Solved Threads: 80
 

Yah, you can set the padding of the table as per the space required.

sarah newton
Junior Poster in Training
64 posts since Feb 2011
Reputation Points: 6
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: