Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1499 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

Pixels to EM (or %)

Thread title: Pixels to EM (or %)
Closed Thread    
    Thread tools Search this thread Display Modes  
07-20-2008, 07:41 PM
#1
Wildcard is offline Wildcard
Wildcard's Avatar
Status: Member
Join date: Jul 2006
Location: soundwave.
Expertise:
Software:
 
Posts: 379
iTrader: 12 / 100%
 

Wildcard is on a distinguished road

Send a message via MSN to Wildcard

  Old  Pixels to EM (or %)

I'm looking for a bit of help on how to convert px to em (or %'s). I've been using px for a while now and just want to know how to convert for expandable layouts

Any help is appreciated!
- Wildcard.

07-20-2008, 08:09 PM
#2
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Edit: You wanted a different answer.

07-21-2008, 12:56 AM
#3
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old

I recoded my portfolio for this:
http://files.xhtmlthis.com/xhtmlthis/

Here is the stylesheet:
http://files.xhtmlthis.com/xhtmlthis/style.css

A tricky thing about using em's, is if you have a <p> inside a <div>, the <p> inherits the <div>'s em size, not the body...it's like that with px, but with EM's it's different, you will see for yourself. Basically if you want 46px height, you use 4.6em. Look at the body tag and html tag, that will get you started. If you need any more help, just PM me.

@andrew: What Wildcard is asking about is elastic layouts, not fluid...at least based on the em's for width. A fluid site is like http://tuscany.cssmastery.com/, a elastic site is like www.SimpleBits.com, where you can change the font size and the layout will accompany it, they are two different things. Although you can combine them just as easy.

07-24-2008, 10:39 PM
#4
Superuser Account is offline Superuser Account
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 15
iTrader: 0 / 0%
 

Superuser Account is on a distinguished road

  Old

an em is a function of your current font size

% is a function of your current window size

due to these consideration the conversion factor from px to em or % is not set and can change

even working with "standard ems" different browsers ship with different default fonts, and macs and pcs have different default fonts

that being said, the conversion is often around 16px to 1em..... but this is user, browser, and computer dependent

here's a neat calculator, but again it's not really that useful
http://riddle.pl/emcalc/

conversion is very tricky if you have an pictures involved..... ideally you want to set the width of your pictures in ems so that they expand and contract w/ the text, but this is often not practical or ideal


garrett's page (that he showed in this thread) is a very nice example
http://files.xhtmlthis.com/xhtmlthis/
the page expands very nicely with the font size
however even this page gets all screwed up if you REDUCE the font size.... since the xhtmlthis logo doesn't shrink with the font, it ends up overlapping everything

to put it succinctly, making fluid layouts is hard, and you'll end up compromising.... but just think in terms of ratios

08-03-2008, 12:03 PM
#5
rochow is offline rochow
rochow's Avatar
Status: Member
Join date: Oct 2006
Location: Australia
Expertise:
Software:
 
Posts: 297
iTrader: 4 / 100%
 

rochow is on a distinguished road

Send a message via MSN to rochow Send a message via Skype™ to rochow

  Old


to put it succinctly, making fluid layouts is hard
Some designs are easy, other designs are literally impossible, especially on the shrinking side of things (not that many people turn the font size down, mind you)

08-03-2008, 08:42 PM
#6
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Originally Posted by Garrett View Post
I recoded my portfolio for this:
http://files.xhtmlthis.com/xhtmlthis/

@andrew: What Wildcard is asking about is elastic layouts, not fluid...at least based on the em's for width. A fluid site is like http://tuscany.cssmastery.com/, a elastic site is like www.SimpleBits.com, where you can change the font size and the layout will accompany it, they are two different things. Although you can combine them just as easy.
I know what the difference is. I just wasn't sure exactly what he was asking about.

08-03-2008, 09:18 PM
#7
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old

Originally Posted by Superuser Account View Post
an em is a function of your current font size

% is a function of your current window size

due to these consideration the conversion factor from px to em or % is not set and can change

even working with "standard ems" different browsers ship with different default fonts, and macs and pcs have different default fonts

that being said, the conversion is often around 16px to 1em..... but this is user, browser, and computer dependent

here's a neat calculator, but again it's not really that useful
http://riddle.pl/emcalc/

conversion is very tricky if you have an pictures involved..... ideally you want to set the width of your pictures in ems so that they expand and contract w/ the text, but this is often not practical or ideal


garrett's page (that he showed in this thread) is a very nice example
http://files.xhtmlthis.com/xhtmlthis/
the page expands very nicely with the font size
however even this page gets all screwed up if you REDUCE the font size.... since the xhtmlthis logo doesn't shrink with the font, it ends up overlapping everything

to put it succinctly, making fluid layouts is hard, and you'll end up compromising.... but just think in terms of ratios
I could have just had the XHTML This logo as a <img> and I would have been fine, but I was just changing my CSS not HTML.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed