SunQuest
           CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 8th, 2003, 10:39 AM
heyder heyder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: t.o.
Posts: 82 heyder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 55 sec
Reputation Power: 7
centering text with css horizontally and vertically

I've seen quite a few articles on CSS Layout Techniques and how tables are bad etc... so I thought I would give CSS another chance as far as page layout goes.

I'm simply trying to center some text on a page both horizontally and vertically. Using tables I would use the following code:


<html>
<head>
<title>center</title>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle">center this text</td>
</tr>
</table>
</body>
</html>



With css ??? (this centers horizontally)

<html>
<head>
<title>center</title>
<style type="text/css">
<!--
.center {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
text-align: center;
margin: auto;
}
-->
</style>
</head>
<body>
<div class="center">this is centered</div>
</body>
</html>

I'm sure there has to be a simple solution but???



I found these links might be of interest

http://archivist.incutio.com/viewlist/css-discuss/11732
http://lists.w3.org/Archives/Public...97Nov/0147.html

Reply With Quote
  #2  
Old September 21st, 2003, 11:14 PM
bodoni's Avatar
bodoni bodoni is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 19 bodoni User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 25 sec
Reputation Power: 0
frankly, you might want to stick with your old reliable tables, which you may find will have more support cross-browser.

afaik there is no sure-fire, reliable way to do this with css. if anyone knows of a way, please speak up.

i think that the way that is officially recognized by the css2 spec is
Code:
.centered {
__position: absolute;
__top: 0;
__right: 0;
__bottom: 0;
__left: 0;
__width: 50%;
__height: 50%;
__margin: auto;
} 

but...well, just try it across various browsers...

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > centering text with css horizontally and vertically


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway