Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2004, 09:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default page sizing

I know this is open to debate, but what page size do any of you design to now? do you go for the 100% of the page or do you go for 760 x 420 or what?!

Any thoughts greatly appreciated.

thanks

Adam

 
Old October 20th, 2004, 08:54 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

This is an age old question, and one that standards proponents will be quite passionate about. This can also become quite a lengthy topic, so I'm not going to go into all of the details.

To make a long story short, you don't have to have a pixel-perfect design or target one particular resolution anymore. In the web's earlier days, before standards took root this wasn't as easy to do. In fact, it's much better if you design with the thought in mind that you won't be able to keep a pixel-perfect design and still have cross-browser, cross-platform and cross-resolution compatability. There's even another variable on top of this, the user's font size preference.

This is where CSS really shines. You can create a design with minimum and maximum dimensions. For instance, a design that expands when there is more screen real estate, and shrinks when there is less and zooms to accomodate a user's font preferences. This is called liquid design. You might think that it's done by specifying length in percentages. In reality, percentages actually don't play a large role in this. It's better to use block elements like <div> elements. Block elements use a width sizing algorithm known as expand to fit. In that light, writing:

div {
    border: 1px solid black;
}

<div>
   This div expands to fill all the space available to it.
</div>

This <div> fills all the space horizontally, that's because it is a block element with auto width by default. You might think that,

div {
    border: 1px solid black;
    width: 100%;
}

...is the same, but it isn't. That's because a percentage measurement doesn't follow the same algorithm. A percentage measurement is based on the width of the containing block. When you apply that rule in a browser you'll see that a horizontal scroll bar appears. That's because width + borders + padding + margin = size of div. 100% of the containing block (the body element), added to 2 pixels of border on both sides equals more space than is available to the div causing horizontal scroll bars.

To get the width to stop shrinking at a certain point and stop expanding at a certain point, you use the min-width and max-width properties.

div {
    border: 1px solid black;
    min-width: 300px;
    max-width: 700px;
}

If you run this one in a browser that understands minimum and maximum widths, such as Mozilla Firefox, you'll see the <div> stops expanding when it reaches 700 pixels and stops shrinking (when you make the browser window really small) at 300 pixels.

Of course that's an oversimplified example, but it's one component of the foundation of a liquid design. These techniques can get rather complicated, and is why the CSS learning curve is much steeper than the HTML learning curve. That said, here is a link to look to for more information:
http://css-discuss.incutio.com/

That's a wiki for the CSS-Discuss mailing list, which many CSS experts contribute to.

You can also see this in a couple sites I have designed:
http://www.smilingsouls.net and http://www.chokoloskee-island.com

View these in Firefox, expand the browser window and shrink it, then increase the font size (ctrl + + && ctrl + -), you should see the whole design scale with the font size. Internet Explorer doesn't play as nice, I've just done as much hacking as required to get these *viewable* in IE... so some of these bells and whistles don't work so well in IE. That bit with the design scaling with the font size is done using em measurements. One em unit is equal to the size of the font for that element, so if the font size is 16px, 1em = 16px.

Hope I've fed your curiousity!

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old November 2nd, 2004, 01:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

thanks Richard - think I'll digest this and then have a go at a 'liquid' design.







Similar Threads
Thread Thread Starter Forum Replies Last Post
IMAGE SIZING glisando Dreamweaver (all versions) 0 January 2nd, 2006 12:11 AM
Image Sizing and Format Changes igor Access VBA 2 December 20th, 2004 04:16 AM
Re sizing according to screen resolution rsamanthif VB How-To 2 August 22nd, 2004 01:24 PM
sizing a form gisvb Dreamweaver (all versions) 2 December 29th, 2003 02:54 PM
Image Sizing Question kilika VBScript 0 July 10th, 2003 01:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.