Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Hybrid Css Layouts, What is the right way to create them?
darran
post Mar 13 2008, 02:36 AM
Post #1


Privileged Member
*********

Group: Members
Posts: 661
Joined: 31-August 06
From: Singapore
Member No.: 29,189



I was looking for a hybrid layout where the header and footer are set to full percentage width and the content is set to a fix width, a very popular layout in today's websites. Do you think you could provide such an example? Not that I do not know how to create one, I just want to know about the right way to actually layout with such specifications.
Go to the top of the page
 
+Quote Post
jlhaslip
post Mar 13 2008, 03:32 AM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,993
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict template</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="keywords" content="keywords list here, comma seperated" />
<meta http-equiv="description" content="insert a description here." />
<meta http-equiv="reply-to" content="jlhaslip@yahoo.ca" />
<meta http-equiv="author" content="Jim Haslip" />
<style type="text/css">
/*<![CDATA[*/
/* =======
Template CSS
============*/
* html { margin:0; padding:0;}
html, body { height: 100%; }
#wrapper { min-height: 100%; } /* div you want to stretch */
body { margin:0 auto; text-align:center; font-size: 62.5%;}
p { margin: 1em; padding:1em; text-align:left }
#wrapper { margin: 0 auto; width: 100%; }
#header { margin: 1em 0; text-align:center; border-bottom: 1px solid #666666; }
#header h1 { margin: 1.8em 0; }
#page_contents { text-align: left; }
#footer { margin: 1em auto; padding: .9em; text-align:center; border-top: 1px solid #666666; }
#footer a { margin: 1em auto; padding: .15em; }
/* =======
Page specific CSS Below this line */

#content_section {

// width: 80%; // tests okay using 800px, 60em. see below.
// what you might have is a problem with font size in different Browsers.
// IE, for instance is about 50% larger than FF2/3.
// font-size adjusted to 62.5% in the body and use ems to size everything gets them 'close'.
// em sizing is also suitable for accessibility (sp?). the div scales with changes to the font size (by the User).

// width: 800px;
width: 80em;;

min-height: 300px;
border: 1px solid green;
margin: 0 auto;
text-align: center; // for older IE browsers. use text-align: left; on the inner div's
background-color: blue;

}
/*============*/
/*]]>*/
</style>
<!--[if lte IE 6]>
<style type="text/css">
#wrapper { height: 100%; }
#content_section { height: 300px; }
</style>
<![endif]-->
</head>


<body>

<div id="wrapper">
<div id="header">
<h1> ... Page Header here ... </h1>

<!-- header --> </div>

<!-- header -->
<div id="page_contents" style="padding: 1em;">
<div id="contentheader" ></div>

<div id="content_section" >
<p>add content here</p>
</div>

</div>

<div id="footer" style="clear: both;"> <a href="http://validator.w3.org/check?uri=referer">validate
the xhtml</a>&nbsp;&nbsp;&copy;&nbsp;<a href="http://jlhaslip.com/">jlhaslip.com</a>&nbsp;&nbsp;<a href="http://jigsaw.w3.org/css-validator/">validate the css</a>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/ca/"><img alt="Creative Commons License" style="border-width: 0pt;" src="http://i.creativecommons.org/l/by-sa/2.5/ca/88x31.png" /></a>
This script is licenced under a
<a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/ca/">Creative
Commons Licence</a>. </div><!-- footer -->
</div><!-- wrapper -->
</body>
</html>

See the notes about the use of ems for font and div sizing.
Go to the top of the page
 
+Quote Post
darran
post Apr 1 2008, 01:41 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 661
Joined: 31-August 06
From: Singapore
Member No.: 29,189



That is exactly how I would create a hybrid layout but 1 question?

I tend to define my base font size with px and everything else later in em because 1em in a 12px is 12px and 0.95em is 11px and so on and so forth. For DIVs, I just use px too.

What is the significance of using em all the way? It will become something very relative.
Go to the top of the page
 
+Quote Post
jlhaslip
post Apr 1 2008, 01:47 AM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,993
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



IE has problems with text re-sizing of pixel based pages, which is a really good feature to have if you want/need a more accessible site, so using ems solves this problem.
The percent size of Font on the Body tag brings IE font-sizes in-line with the other Browsers. Without the 62.5% there, IE will display larger font sizes by default and using this technique allows you better font management across multiple browsers.
Go to the top of the page
 
+Quote Post
darran
post Apr 1 2008, 01:53 AM
Post #5


Privileged Member
*********

Group: Members
Posts: 661
Joined: 31-August 06
From: Singapore
Member No.: 29,189



QUOTE(jlhaslip @ Apr 1 2008, 09:47 AM) *
IE has problems with text re-sizing of pixel based pages, which is a really good feature to have if you want/need a more accessible site, so using ems solves this problem.
The percent size of Font on the Body tag brings IE font-sizes in-line with the other Browsers. Without the 62.5% there, IE will display larger font sizes by default and using this technique allows you better font management across multiple browsers.


Once again it is IE. So lets say if I put 1em as the margin-right for my DIV, what is the exact spacing in pixels it will generate?

I will be sure to note this when I get down to coding my WordPress template.
Go to the top of the page
 
+Quote Post
rvalkass
post Apr 1 2008, 09:48 AM
Post #6


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,111
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



QUOTE(darran @ Apr 1 2008, 02:53 AM) *
Once again it is IE. So lets say if I put 1em as the margin-right for my DIV, what is the exact spacing in pixels it will generate?

I will be sure to note this when I get down to coding my WordPress template.


There is no way to tell. It will depend on the browser and its settings. As one em is the width of an 'm' in the current font, at the current font size, the margin would change depending on which font and font size the browser was using.
Go to the top of the page
 
+Quote Post
darran
post Apr 2 2008, 01:24 AM
Post #7


Privileged Member
*********

Group: Members
Posts: 661
Joined: 31-August 06
From: Singapore
Member No.: 29,189



QUOTE(rvalkass @ Apr 1 2008, 05:48 PM) *
There is no way to tell. It will depend on the browser and its settings. As one em is the width of an 'm' in the current font, at the current font size, the margin would change depending on which font and font size the browser was using.


So there is no way of setting a fixed layout which will look the same? I want to have a layout which will look the same in every browser. Let's say I am using Arial with font size: 100%, I do know that IE uses 12px for that, but I am not sure about Safari, FireFox and Opera.
Go to the top of the page
 
+Quote Post
jlhaslip
post Apr 2 2008, 02:01 AM
Post #8


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,993
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Try specifying a particular font-face, font-size and font-weight then check it in a few Browsers.
Use the body font percent code found above if they display differently and use em's as above is the cure I use.
Go to the top of the page
 
+Quote Post
darran
post Apr 2 2008, 12:38 PM
Post #9


Privileged Member
**