tags:

views:

75

answers:

2

Hi, I am fairly new to CSS and I wanted to know how can achieve this:

I am writing a page that will display a form in the middle (Represented by the black box). I want it to have white background that will overlap the body background (represented by the red lines).

Check out this site for the example image. (Sorry I couldn't post it inline)

http://www.freeimagehosting.net/uploads/bf2d71f238.png

Thank you very much!

A: 

Go read a book like 'CSS Mastery'. Once you know some basics and can explain what you tried and have a basis for asking a question in the first place, then ask for help.

Frank Schwieterman
I disagree - I learned ALL my css from experimentation and reading web articles. I don't mind giving users a quick boost to get them up and running. Once they see enough examples - they'll figure out how the generalities work and experiment on their own.
yuval
@Frank - why bother answering if what you are writing is useless?
alexBrand
I disagree with the downvote. A book recommendation adds to the discussion. Now it might not help the guy with his immediate question, but IMO even if this is not the best answer, it can be helpful if the poster is interested in digging deeper. My only comment is that if you're going to post a book recommendation, put in a link.And yuval: If you haven't read a whole book on CSS, chances are you are missing a lot of the big picture about CSS. I tried learning by rote myself for the past 5 years or so, and finally picked up a book and read it cover to cover.
Dave Markle
I don't think my advice is useless. Its what the questioner should do.
Frank Schwieterman
+3  A: 

You can give your elements a few styles, background can be color, images, etc.

CSS:

body { /* Red Lines Here */
  background: #990000;
}
#outer { /* White box Here */
  background: #ffffff; /* White */
  width: 900px; /* Total width will be 1000px once you include padding */
  padding: 50px; /* White border around black box, this is padding on all sides */
  margin: 0 auto; /* Centering it */
}
#inner { /*Black Box Here */
  background: #000000; /* Black */     
  color: #ffffff; /* White Text so you can see it */ 
}

Html:

<html>
  <head>
    <title>My Page! Step off!</title>
  </head>
  <body>
    <div id="outer">
      <div id="inner">
        Content!
      </div>
    </div>
  </body>
</html>
Nick Craver
+1 - beat me to it :P
yuval
Using two divs seems a bit overkill. What is wrong with "border:50px solid #FFF;"?
kloffy
@kloffy - If it was me, I'd want an image in that space, starting him off with that option later :)
Nick Craver
thank you! I will post my code for the next time!
alexBrand
I guess it always depends on how much flexibility is required. My point was just not to overly complicate the structure of the HTML as long as there is no real reason for it. Good detailed answer, though!
kloffy