Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

When centered how do i place content within.

Featured Replies

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.

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.

  • 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?

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>

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/

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.