PDA

Click to See Complete Forum and Search --> : css - pixels or percents


dyers78
05-29-2007, 07:55 PM
I started setting up a new site then let it go for two months. Now I am back at it and forgot everything I just learned. My question:

when I am nesting div tags shuld I use % or stick with pixels? for example:

My overall container which is centered is set to a fixed width of 900px (I know 800 is the norm but I need the room) then I have two nested divs inside both floated left - one at 698px with 1 point borders (total 700px wide) and the other set at 200px wide no border totaling 900px wide.

this gets me my framework. Now what is the rule for divs inside the 698px div? I will have a header div, body div and footer div. Right now they're at 100% wide, is it better to stick with pixels is it ok to mix pixels with percentages? any advantages to either in this instance?

tZ
05-29-2007, 09:49 PM
one of the large promblems assciaated with percents is long text lines.

when you use pixels your working at a fixed width. So if someone is viewing your ite on a smaller screen the the site may be cut off or need to scroll horizontally. However, if you use percentages you won't need to worry about this as the site width and height will be based on a percentage of the screen.

However, when you set your font size what may happen is it may force text nto all te wrong places for the layout becasue certain boxes may get to small or vice versa and expand your lines. Howeever, when you use a fixed width you have pretty much total control.

You could also look into using a elastic layout(ems). I'm not going to explain them right now but, then you can control the size of text and divs at the same time. The only caution there is text becoming to large. Since, an em is a set percentage.

The main types of layouts are:

fixed (pixels)
liquid (percentage)
elastic(ems)

Then there is hybrid layouts that are a combinition.

In any matter it all depends on your target audience and screen.

For more info on these things though check out CSS mastery. It goes in -depth explaining all the positives and negatives of these variety of approaches and its where I learned about it.

http://www.amazon.com/CSS-Mastery-Advanced-Standards-Solutions/dp/1590596145/ref=pd_bbs_sr_3/002-2216584-5291243?ie=UTF8&s=books&qid=1180475292&sr=8-3

It all depends on what your trying to accomplish though.

Thats all I remember currently but, I'm sure others will chime in.

dyers78
05-30-2007, 12:19 AM
I understand how the different units work. I guess I am asking if it's ok to mix them. I have a bug in my layout that makes it wrap in some older browsers when it's not supposed to. I want it to be perfect before I continue building the rest of the site.

My current layout is fixed width (the frame anyways) but some of my nested divs are set in percents. I am not sure why I did it this way(???) and like I said, it's been a while since I put this down.

If there are no issues with it then I am good - I can't find anything that says otherwise. I will check out that link, thanks!