Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to be able to have my website centered but not take up the space around it, what I am trying to do is have my website centered but then have a side box outside of the main site that takes up the space in the left margin, the margin:auto; or margin: 0 auto; in css doesn't work because then the div takes up the space in the margins and there is no room for anything else, and there is no float:center; Any and all help is appreciated.

-Jordan

Screenshot of how the site is now: https://skydrive.live.com/redir?resid=BA174670C15415EE!111&authkey=!AAjj6qxMvhQz_IY[^]
Posted
Updated 15-Dec-12 19:45pm
v3
Comments
[no name] 16-Dec-12 1:05am    
could you please attach screen shot of it ??
Sicppy 16-Dec-12 1:30am    
of how it is now
or do you want me to make a rough sketch of how I want it?
[no name] 16-Dec-12 1:31am    
Take a screenshot and upload it on sky drive or dropbox etc... and provide us link..
[no name] 16-Dec-12 1:47am    
Now tell the exact problem that you're facing...
Sicppy 16-Dec-12 1:50am    
I told you, I need to know how to keep the site centered while still being able to put stuff in the margins

1 solution

You need to use both auto in the style:
CSS
margin-left:auto;
margin-right:auto;


This is somewhat counter-intuitive, but works correctly.

—SA
 
Share this answer
 
Comments
Sicppy 25-Dec-12 1:28am    
Two things, first, using the margins would take up the space in the margins not allowing me to put a div there, second, using margin: 0 auto; gets the job done, I recommend using that instead
Sergey Alexandrovich Kryukov 25-Dec-12 1:43am    
You are saying strange thing. If you want to center anything, it assumes that there is a space on left and right which you need to distribute evenly. What "take up space" do you mean? If you see that margin: 0 auto solves your problem, what's the problem though?
—SA
Sicppy 1-Jan-13 18:24pm    
I was saying that margin: 0 auto; and magin-left:auto; margin-right:auto; accomplish the same thing, and neither of them solve my problem, I want to put a nav box in the margin, but I cant because it floats above or below the margins.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900