Reply
Css pixels to percents
Old 11-06-2009, 02:18 PM Css pixels to percents
Junior Talker

Posts: 2
Name: Jakob
Trades: 0
I have been building a website for a client and created it initially in pixels. However, this was not the best idea as the client is now asking for me to change it to percents.

I can not find an easy way to change everything over to percents and it killing me

I have used many divs in the document - and 1 table.

I have read how to convert it using simple math - but every time I try it does not turn out.

Is there an easy way to change it over? Or do I have to go through the process of resizing all pictures etc?

I am using a style sheet. Gah - I knew I bit off more then I could chew! haha

I tried to change the style sheet last night for a good 4 hours and had to revert back to my original save.

I am just very confused when I set the main div a lets say 75%. Then I have two columns inside that div - which were set at 20% and 80%. This made the second column jump down to the next line - and also didn't change any of the text or pictures within side the divs.

hmmmmm

These divs also have cell padding - which I assume is part of the problem?

Thanks,

Very confused Jakob
Ashtel is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-06-2009, 03:48 PM Re: Css pixels to percents
orionoreo's Avatar
Ultra Talker

Posts: 261
Name: Jerry
Trades: 0
the 20 + 80% works if there's no padding and border and margin only I would guess

why does your client want the css in percentage? so it stretches with the viewport? show us an example

there's no easy formula or converter to do so
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 11-06-2009, 04:05 PM Re: Css pixels to percents
wayfarer07's Avatar
NYE-KEE

Posts: 3,150
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
One thing you can do is uses em instead of %, in a way that will exactly imitate px sizes at default browser font settings. It works like this:

CSS
Code:
body {
    font-size: 62.5%;/*this becomes the parent size for the entire document*/
}
Now, any pixel size expressed em will be equivalent to the px quantity one decimal place over. In other words, 1em is equal to 10px at default browser font settings:
Code:
p {
    font-size: 1.1em; /*same as 11px*/
}
The advantage of sizing fonts this way is that they may now be re-sized by the user. This same principal may be used for anything, not just font-size, but you must remember, em is proportional to the parent, which means you must be careful.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola

Last edited by wayfarer07; 11-06-2009 at 04:07 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-06-2009, 05:34 PM Re: Css pixels to percents
chrishirst's Avatar
Super Moderator

Posts: 22,223
Location: Blackpool. UK
Trades: 0
BTW <div>s don't have "cell" padding.

<div>s are also block elements which means they have an implied linebreak above and below so they are the only element to occupy the horizontal space.

You need to set the width of your left hand column and float it left, then allow the right column to take up the rest of the space.

http://www.modtalk.co.uk/_site/layout/two-column/
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-10-2009, 03:55 PM Re: Css pixels to percents
Junior Talker

Posts: 2
Name: Jakob
Trades: 0
Deleted - thanks for help

Last edited by Ashtel; 11-11-2009 at 12:59 PM..
Ashtel is offline
Reply With Quote
View Public Profile
 
Old 11-10-2009, 06:40 PM Re: Css pixels to percents
Average Talker

Posts: 16
Trades: 0
Be sure to include a css reset stylesheet along additional styles to deal with unexpected padding/margin issues.

- If client's wish for a fluid layout is related to the horizontal scroll required by visitors utilizing lower resolution, perhaps sticking to a 960px width would make them happier (will still require a bit of a horizontal scroll for lower resolution, but it's a pretty reasonable compromise)

Fluid layouts have their bonuses, but also have potential to leave your site looking a bit ridiculous considering the content has to grow/shrink from 800x600 to 1680x1050 or greater and every size in between.
whatsherface_21 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Css pixels to percents
 

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 0.12387 seconds with 13 queries