January 21, 201016 yr I know how to centre a website as ive seen it on here.But how do you place content within the centered div container?. Ive been struggling placing items in the div were i want them.
January 21, 201016 yr What kind of problems are you having? Things placed within the div should appear relative to the container i.e. inside it
January 21, 201016 yr CSS: *{ text-align:center; /* Because IE is lame */ } p{ text-align:left; /* Because IE is really lame */ } #container{ margin:0 auto 0 auto; width:750px; } HTML <div id="container"> <p>Content here will be centered</p> </div> Just replace the paragraph with further <div> tags as you require, the position of the nested <div> tags will be relative to the width and height of their parent and neighbouring tags. Remember to use positioning or float.
January 21, 201016 yr Author CSS: *{ text-align:center; /* Because IE is lame */ } p{ text-align:left; /* Because IE is really lame */ } #container{ margin:0 auto 0 auto; width:750px; } HTML <div id="container"> <p>Content here will be centered</p> </div> Just replace the paragraph with further <div> tags as you require, the position of the nested <div> tags will be relative to the width and height of their parent and neighbouring tags. Remember to use positioning or float. what do i use relative positioning?
January 21, 201016 yr what do i use relative positioning? You need to use float and positioning techniques to position the content areas. Here's a very simple example; CSS: *{ text-align:center; /* Because IE is lame */ margin:0; padding:0; } p{ text-align:left; /* Because IE is really lame */ } #container{ margin:0 auto 0 auto; width:750px; } #left{ float:left; width:500px; } #right{ float:left; width:250px; background-color:#999; } HTML <div id="container"> <div id="left"> <p>Main content area</p> </div> <div id="right"> <p>This is a sidebar</p> </div> </div>
January 22, 201016 yr is it wrong to use relative within a container then? No, but relative and absolute positioning should be used with caution. Their are times when it is necessary, but when it's abused catastrophe will strike. Floats are difficult to grasp to begin with, however are far more stable and flexible in the long run. Here's a good article on floats, i'll have a look for one about the pro's and cons of positioning. http://www.digital-web.com/articles/web_design_101_floats/
January 22, 201016 yr is it wrong to use relative within a container then? Sorry for a late reply. No, it's not 'wrong', but I just suggest you get to grips with floats with margins and padding. Very simple once you've got over the first hurdle. You can do anything with floating divs! You need to understand the purpose and usage of the CSS 'clear' property too. Lack of this can cause serious display issues.
Create an account or sign in to comment