William Smith
William Smith

Reputation: 852

Adding color to margins in CSS

I'm using this code to center/position a fixed width image as my background. I need to add color around the image that fills the margins in the browser window. I've tried background color, border color...

So, the width of the image is 1050px. If the browser window is 1500px I want to make the remaining area black (for instance). How can I do this?

#content {
    text-align: left;
    width: 1050px;
    height: 825px;
    margin: 0 auto;
    padding: 0px;
    background-image: url(file:///X|/CarFingers/tabback1_hor.png);
    background-repeat: no-repeat;
} 

body {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333333;
    text-align: center;
}
<div id="content">
<body>

</body>
</div>

Upvotes: 0

Views: 5357

Answers (4)

Muhaimen Ezabbad
Muhaimen Ezabbad

Reputation: 7

#content {
    text-align: left;
    width: 1050px;
    height: 825px;
    margin: 0 auto;
    padding: 0px;
    background-image: url('file:///X|/CarFingers/tabback1_hor.png');
    background-repeat: no-repeat;
} 

body {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333333;
    text-align: center;
    background-color: #000;      /* Add this to your code */
}

In your html you should do something like this:

<body>
   <div id="content">
   </div>
</body>

You should never enclose the BODY in DIV

Upvotes: 1

Steven Mcsorley
Steven Mcsorley

Reputation: 81

If you are wanting to know how to color a border in CSS it would be

border: 10x solid #000;

or

border-width: 10px;
border-color: #000;
border-style: solid;

Upvotes: 1

Luuuud
Luuuud

Reputation: 4439

First: put the div INSIDE your body. Then you can just edit your body background like this:

body{
    background-color: black;
}

Upvotes: 7

Cecchi
Cecchi

Reputation: 1535

Your HTML is invalid, you should not have a div tag enclosing the body tag. If you put the div within the body you should be able to simply set the background color of the body.

Upvotes: 4

Related Questions