Problem centering an element

  • JasonStanley
  • Graduate
  • Graduate
  • JasonStanley
  • Posts: 124
  • Loc: London, England

Post 3+ Months Ago

I have built a new site which contains a mac font. This font is not available on windows. The windows alternative is of less width.

I have always done the following.

#element {margin:0 auto; width:xxx; }

The problem is that the element width varies depending on the font. Is there a way to center an element without declaring it width?
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6229
  • Loc: South-Africa

Post 3+ Months Ago

padding:auto; ... ?
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5146
  • Loc: SC-USA

Post 3+ Months Ago

percentage based layout with body margins.
  • JasonStanley
  • Graduate
  • Graduate
  • JasonStanley
  • Posts: 124
  • Loc: London, England

Post 3+ Months Ago

righteous_trespasser wrote:
padding:auto; ... ?


What has padding got to do with centering?

digitalMedia wrote:
percentage based layout with body margins.


Can you elaborate on this please.
  • murcielagossi
  • Proficient
  • Proficient
  • User avatar
  • Posts: 457

Post 3+ Months Ago

if you cant get the width with css, use the <center></center> tags
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5146
  • Loc: SC-USA

Post 3+ Months Ago

JasonStanley wrote:
Can you elaborate on this please.


I hope I understood your initial post correctly.

A percentage based site can give the illusion of being centered and your text can wrap freely regardless of the font.

Example:
http://www.myirmo.com/sbuni/
  • dogbert
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Tacoma, WA

Post 3+ Months Ago

what about picking a diff font to fall back on like this:

h1 {font-family: "MAC FONT", Times New Roman;
font-size: 12px;}

just pick a windows font that looks the same or is the same size.

using margis could work for centering if you new the width and the apoximate width/range of width of the box you could set the margins on both sides to hold it in the middle but its a poor solution. (or atleast I think so)

yeah <center> should do just fine

Quote:
A percentage based site can give the illusion of being centered and your text can wrap freely regardless of the font.

Example:
http://www.myirmo.com/sbuni/

be carefull because as with that example its not fully % based, the pic and menu cary over the edge and off the window when it gets to small.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 26 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.