WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts

WeLoveCSS > WEB DESIGN > CSS > [PROBLEM] CSS + Div + Center Positioning

  Thread Tools Display Modes
Old 28th February 11, 01:31 PM   #11
WLC Lover
LearningCoder's Avatar
Join Date: Jan 2011
Location: England
Posts: 115
Default Re: [PROBLEM] CSS + Div + Center Positioning

Originally Posted by meesa View Post
Keep in mind though that margin:auto only works to center something when the element also has a set width.
That's correct.

Your code could be:

.centerdiv {width: 50%;
margin-left: auto;
margin-right: auto;}

This will effectively put your div, which is 50% of the page, into the center leaving 25% each side. (Although you wouldn't be able to add any elements either side of this div, as the 25% is in effect the margin space.)

To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
LearningCoder is offline   Reply With Quote

Thread Tools
Display Modes
Linear Mode Linear Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:53 PM.

Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyrightę 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.