Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Old 09-22-2007, 01:30 PM centering the body
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
i have a page with just a small amount of content (tho' unknown size as content is dynamically produced) and i want the content to be centered both vertically and horizontally.

is there a way to just set the valign=middle and align=center for the body tag itself.

fyi, i'm on FF for Mac.


cheers folks


;purk
__________________

Please login or register to view this content. Registration is FREE
- private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
 
Register now for full access!
Old 09-22-2007, 02:12 PM Re: centering the body
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
I think that the easiest way to do that would be to put this in the style sheet:

Code:
body {
text-align: center;
}
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 09-23-2007, 12:51 AM Re: centering the body
Silent77's Avatar
Ultra Talker

Posts: 269
Name: Silent
Location: Ohio
Trades: 0
HTML Code:
<body style="text-align:center">
    <div style="text-align:left">
        <!-- Content -->
    </div>
</body>
__________________
Firefox
rediscover the web

Please login or register to view this content. Registration is FREE
Down with internet explorer!

Last edited by Silent77; 09-23-2007 at 11:02 PM..
Silent77 is offline
Reply With Quote
View Public Profile Visit Silent77's homepage!
 
Old 09-23-2007, 11:25 AM Re: centering the body
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
There is currently no easy way to vertically center using html or css alone. Valign is for tables - period. Vertical-align pertains only to the baseline of text.

You might be get some results using percentages on top and bottom margins on the element to be centered.

Horizontal centering is easy, but text-align:center on the body is only part of the solution - for IE. UPut a width on they div, then use margin: 0 auto; to center in other standards-compliant browsers.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 12:11 PM Re: centering the body
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
There's a pretty easy way with CSS to make something be in the middle of the page. I've done it before. It's pretty nice.

If you want to know how, tell me.
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 09-23-2007, 12:15 PM Re: centering the body
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
Quote:
Originally Posted by coolkbk585 View Post
There's a pretty easy way with CSS to make something be in the middle of the page. I've done it before. It's pretty nice.

If you want to know how, tell me.
I thought that was the point of this thread
joder is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 12:26 PM Re: centering the body
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
Quote:
Originally Posted by joder View Post
I thought that was the point of this thread
o_O Fine.

Well, what you would do would be with CSS.

You would put your page into a div. Then you would choose how high and wide you want your page to be. Then you would fill in the margins. It's half of the heights and widths. Don't forget to leave the "-" sign there.

HTML Code:
<style type="text/css">
div#container {
height: HEIGHT px;
width: WIDTH px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -HALF OF THE HEIGHT px;
margin-left: -HALF OF THE WIDTH px;
}
</style>
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 09-23-2007, 04:05 PM Re: centering the body
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
Thanks Kyle! This is going in my folder with CSS code snippets

EDIT: I've given out too much TP in the last 24 hours. When I get the chance, since your at 99, you'll get another green dot.

Last edited by joder; 09-23-2007 at 04:07 PM..
joder is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 06:17 PM Re: centering the body
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Here's something I did a long time ago now;

http://www.candsdesign.co.uk/page-te...tre/layout.asp

the code is at;
http://www.candsdesign.co.uk/page-te.../show-code.asp
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-23-2007, 08:02 PM Re: centering the body
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
thanks coolkbk585 that worked perfectly.
__________________

Please login or register to view this content. Registration is FREE
- private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Old 09-24-2007, 07:45 PM Re: centering the body
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Quote:
Originally Posted by coolkbk585 View Post
o_O Fine.

Well, what you would do would be with CSS.

You would put your page into a div. Then you would choose how high and wide you want your page to be. Then you would fill in the margins. It's half of the heights and widths. Don't forget to leave the "-" sign there.

HTML Code:
<style type="text/css">
div#container {
height: HEIGHT px;
width: WIDTH px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -HALF OF THE HEIGHT px;
margin-left: -HALF OF THE WIDTH px;
}
</style>

I am just a little confused about this!?

Your page is going to have different sizes which will vary according to the personal settings of each visitor...
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 09-24-2007, 08:07 PM Re: centering the body
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
No it won't. There are no percents there...it might look bigger because of a lower resolution...but that's it.
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 09-24-2007, 08:33 PM Re: centering the body
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Tried it out!
It does work great!
Good job dude!
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Reply     « Reply to centering the body
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.84092 seconds with 12 queries