Jump to content

How can I remove the white space on the side?


bugzy

Recommended Posts

I'm still learning CSS and I'm really annoyed with the white space that I'm getting on all side of the page eventhough I set the width of the container to 100%.

 

Here's the white space that I'm getting.

 

whiteafl.gif

 

 

Here's my CSS code

 

#container{
width:100;
height:auto;
background-color:#666;
padding-top:20px;
padding-bottom:20px;
}


#header{
width:80%;
height:130px;
background-color:#FFF;
}


#navigation{
width:80%;
height:30px;
background-color:#CCC;
margin-top:10px;
margin-bottom:10px;
}

#body{
width:80%;
height:auto;
padding-top:10px;
padding-bottom:10px;
background-color:#333;
margin-bottom:10px;
}


#left-sidebar{
width:20%;
height:450px;
float:left;
background-color:#CCC;
margin-bottom:10px;
margin-left:30px;
margin-top:10px;
margin-right:20px;
}


#content{
background-color:#FFF;
width:95%;
height:500px;
text-align:left;
padding-left:30px;
padding-top:10px;
}


#footer{
clear:both;
height:30px;
background-color:#CCC;
width:80%;
}


 

 

 

Can someone pls. help get rid of the white space so I can make the full background on whatever color I want w/out the white space on every side?

Link to comment
Share on other sites

try

 

body {margin: 0;}

 

Hey my elements are all inside the container so my technique is just put the background color I want also on the container.

 

I put body {margin: 0;} on the container. Like this:

 

 

#container{
width:100;
margin:0;
height:auto;
background-color:#666;
padding-top:20px;
padding-bottom:20px;
}

 

 

but it doesn't give any effect and white spaces are still there... What do you think?

Link to comment
Share on other sites

So your CSS file looks like this and it still doesn't work??

 

body {
margin:0;
}

#container {
width:100%;
background:silver;
margin:0px;
}

 

 

Ok I tried this..

 

#bg{
margin:0;
}

#container{
width:100%;
height:auto;
background-color:#666;
padding-top:20px;
padding-bottom:20px;
}

 

 

Tried it and it's not working...

 

I'll post all the codes including the html to make it clear..

 

CSS

 

#bg{
margin:0;
}

#container{
width:100%;
height:auto;
background-color:#666;
padding-top:20px;
padding-bottom:20px;
}


#header{
width:80%;
height:130px;
background-color:#FFF;
}


#navigation{
width:80%;
height:30px;
background-color:#CCC;
margin-top:10px;
margin-bottom:10px;
}

#body{
width:80%;
height:auto;
padding-top:10px;
padding-bottom:10px;
background-color:#333;
margin-bottom:10px;
}


#left-sidebar{
width:20%;
height:450px;
float:left;
background-color:#CCC;
margin-bottom:10px;
margin-left:30px;
margin-top:10px;
margin-right:20px;
}


#content{
background-color:#FFF;
width:95%;
height:500px;
text-align:left;
padding-left:30px;
padding-top:10px;
}


#footer{
clear:both;
height:30px;
background-color:#CCC;
width:80%;
}

 

 

 

HTML

 

<body>
<div id="bg">
<div id="container">
<center>

<div id="header">This is the header.</div>

<div id="navigation">This is the navigation</div>

<div id="body">

<div id="left-sidebar">This is the left sidebar</div>

<div id="content">This is the content</div>

</div>

<div id="footer">This is the footer</div>

</center>
</div>
</div>


</body>
</html>

 

 

 

I already have div named "body" so I just named the margin 0 "bg".

 

I'm not sure if I need to put all the divs in div "bg" ?

 

I don't why it isn't still working.. white spaces are still there... 

Link to comment
Share on other sites

you need to set it for both body and html

body, html {
    margin: 0px;
    padding: 0px;
    width:100%;
}

 

Hey thank you guys for all you patience.. I though I will make the "body" a div also with # sign :D

 

Now it's working already :)

 

Thanks guys!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.