|
|
Hybrid Css Layouts - What is the right way to create them? | ||
Discussion by darran with 11 Replies.
Last Update: April 2, 2008, 7:50 pm | |||
![]() |
|
|
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> © <a href="http://jlhaslip.com/">jlhaslip.com</a> <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.
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.
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.
QUOTE (jlhaslip)
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.
Link: view Post: 382545
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.
QUOTE (darran)
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.
Link: view Post: 382546
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.
QUOTE (rvalkass)
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.Link: view Post: 382582
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.
Use the body font percent code found above if they display differently and use em's as above is the cure I use.
I am confused, would appreciate some assistance, it is much more easier setting the layout in px and text size in em.
Or better still, post a link to a page...
Thanks.
I coded the page with ems for fonts and px for everything else.
Simply give the content div a width in pixels and then the inner content should be given a smaller width in pixels and margin: 0 auto to centre it.
Older versions of IE mayl need text-align: center on the outer div to behave in the same fashion.
Similar Topics:
Css Table Layouts
Two Ways To Create A Dll .dll In V...
Help With Css Sytelsheet
Css- Review With Tutorial If u r learning CSS, learn it with me. (2)
|
(7) Problem With Menubar In IE
|
Loading...
HOME 





How To: Basic Customization of SUP 2.0 Hybrid Web Container Apps with JavaScript and CSS
7 Minute Hybrid iPhone app How To with Dashcode & QuickConnectIphone
Develop Mobile Web and Hybrid Apps on Force.com
CSS-Tricks Screencast #10: Fixed Width, Fluid Width & Elastic Width

