[SOLVED] Content

This is a discussion on "[SOLVED] Content" within the Web Page Design section. This forum, and the thread "[SOLVED] Content are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 26th, 2007, 04:16
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Content

How do I center all my content using css as appose to using a table?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 26th, 2007, 05:27
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Content

Well, your sample code will be helpful!

Do you want to center the element itself (your div) or the element inside the div (eg. your <h1> or <p>)?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 26th, 2007, 09:24
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Content

try something like:

Code: Select all
#content {
width: 800px;
height: 1000px;
margin: 0 auto;
}

And your html would be:
HTML: Select all
<div id="content">
content
</div>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 26th, 2007, 09:37
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Content

That would be positioning the div horizontally center.

If you want to center the elements inside the div, you would use:

Code: Select all
 p {
text-align: center;
}
to center up all your paragraph inside the div that Alex just created.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 26th, 2007, 09:44
Up'n'Coming Member
Join Date: Jun 2007
Location: Germany
Age: 23
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

If you want to center your content horizontal and vertically, you can use a wrapper div.
Using fixed pixel values, you can do it this way:
HTML: Select all
...
<body>
<div style='position:absolute; left:50%; top:50%;'>

<div style='position:absolute; left:-200px; top:-100px; width:400px; height:200px; border:1px solid black;'>
This box with a black border is totally centered! How nice.
</div>

</div>
</body>
...
There are alternative versions for % values or non-fixed areas.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 26th, 2007, 09:45
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Content

Monie it will not center all elements, just text.
And personally center aligned text is awful looking, I wouldn't use it!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 26th, 2007, 09:48
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Content

yeap.. It depends on what thewebkid means "content" in his question.
Thanks for clearing that up.

If he got image inside the div, he would just have to put this in his css code:

Code: Select all
#content {
width: 800px;
height: 1000px;
margin: 0 auto;
 text-align: center;
}
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 26th, 2007, 12:29
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

OK sorry for the lack of information I have given you. I will draw you out what I want the basic layout of my website to look like. It's like that "holy grail thing" I just learned a little of CSS in my class and not enough to know how to layout a page. brb with the image
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Oct 26th, 2007, 12:43
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

Quote:
Originally Posted by thewebkid View Post
It's like that "holy grail thing" I just learned a little of CSS in my class and not enough to know how to layout a page.
The "holy grail" is, I believe, a misleading name.

Most websites don't need three columns. Use two columns unless you have a very good reason for three.

Since you're new to CSS, don't attempt complicated layouts. Most of them are pointless anyway, and you'll only confuse yourself.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Oct 26th, 2007, 12:47
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

Then What should I do? I don't want a beginner looking website.(that seems pretty prideful) I want to make i appealing and make it look like I really work hard on it.


......Ok now I am going to be more specific. This here shows the type of layout I want. I can do this with tables, but we all know that's a big RED LIGHT when it comes to web design. I want to be able to apply this to all my web pages(obviously) and have just a plain background color which I will chose later. Thank you for your help.
Attached Images
File Type: jpg layout.jpg (37.2 KB, 8 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Oct 26th, 2007, 12:49
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

See the August editions of the Newsletter ... I have touched this in the FAQ

How do I center my site horizontally?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Oct 26th, 2007, 12:53
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Content

put all of the divs inside a master div and use my first code.
e.g. The CSS:
HTML: Select all
#wrapper {
width: 800px;
height: 1000px;
margin: 0 auto;
}

The html:

HTML: Select all
<div id="wrapper">
<div id="logo"><img> etc. etc.</div>
more divs here...
</div>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Oct 26th, 2007, 12:58
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,794
Thanks: 0
Thanked 17 Times in 17 Posts
Re: Content

From your example to get the div to strech down the page on everyone's screens you will need to kinda hack it.

I found Ryan Fait's (was a webforumz member but isnt as active now!) sticky footer a good example. It can be found here: http://ryanfait.com/sticky-footer/.

Also to center the div you use the margin:0 auto; code
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Oct 26th, 2007, 13:11
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

Guys ... stop repeating yourselves!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Oct 26th, 2007, 13:17
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Content

Ha yeah, seems like everyone has to clarify what everyone else says..
And I now realise by saying this I'm being a hypocrite..
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Oct 26th, 2007, 13:27
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

Have I stirred up trouble?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Oct 26th, 2007, 13:32
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

Not really but next time it would help if you'd be more specific in your opening post!

But then ... the members here are trigger happy and can't wait to help out without even knowing what the OP needs help with
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18  
Old Oct 26th, 2007, 13:37
Reputable Member
Join Date: Oct 2007
Location: At my house
Age: 22
Posts: 193
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Content

lol sorry. I was in a rush and wanted to get the subject going before calling it a day.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19  
Old Oct 26th, 2007, 13:55
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Content

Anyway, did any of the suggestions work?
Or do you need more help?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #20