5

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!

7
  • Probably not the welcome you were looking for at SO, however Frank does have a point. The community will react a lot better if you don't ask them to do all the work for you. Try posting what you have so far, however bad you may think it is. Commented Feb 9, 2010 at 0:13
  • 2
    @Mike - Drawing a picture is better than most! Starting with what you know isn't a bad idea IMO Commented Feb 9, 2010 at 0:15
  • 1
    I second Nick - some people don't know anything to start with Commented Feb 9, 2010 at 0:16
  • There is any level of programming knowledge needed to be SO user? People need to start at the beginning sometime. SO is not just for gurus. Commented Feb 9, 2010 at 0:24
  • 2
    No level of knowledge is needed to be SO user, but there is a level of effort that's needed in order not to be (or appear to be) a help vampire. slash7.com/2006/12/22/vampires Commented Feb 9, 2010 at 1:17

2 Answers 2

3

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>
Sign up to request clarification or add additional context in comments.

3 Comments

Using two divs seems a bit overkill. What is wrong with "border:50px solid #FFF;"?
@kloffy - If it was me, I'd want an image in that space, starting him off with that option later :)
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!
0

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.

4 Comments

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.
@Frank - why bother answering if what you are writing is useless?
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.
I don't think my advice is useless. Its what the questioner should do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.