Loading...


bookmark - Hybrid Css Layouts What is the right way to create them?

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
 
bookmark - Hybrid Css Layouts What is the right way to create them?  
Quickly Post to Hybrid Css Layouts What is the right way to create them? w/o signup Share Info about Hybrid Css Layouts What is the right way to create them? using Facebook, Twitter etc. email your friend about Hybrid Css Layouts What is the right way to create them? Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

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.









   Wed Mar 12, 2008    Reply         

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.

   Wed Mar 12, 2008    Reply         

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.

   Mon Mar 31, 2008    Reply         


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.

   Mon Mar 31, 2008    Reply         

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.

   Mon Mar 31, 2008    Reply         

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.

   Tue Apr 1, 2008    Reply         


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.

   Tue Apr 1, 2008    Reply         

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.

   Tue Apr 1, 2008    Reply         

I can't manage to get the em right on the DIVs, giving me a headache. What does it take reference to? What if it is a div is nested in another div?

I am confused, would appreciate some assistance, it is much more easier setting the layout in px and text size in em.

   Wed Apr 2, 2008    Reply         

Can you post up your code and we'll have a look to see if what you are doing is possible?
Or better still, post a link to a page...

Thanks.

   Wed Apr 2, 2008    Reply         

I will send you a PM as I want to keep my design hush.

I coded the page with ems for fonts and px for everything else.

   Wed Apr 2, 2008    Reply         

Replied by PM.

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.

   Wed Apr 2, 2008    Reply         

Quickly Post to Hybrid Css Layouts What is the right way to create them? w/o signup Share Info about Hybrid Css Layouts What is the right way to create them? using Facebook, Twitter etc. email your friend about Hybrid Css Layouts What is the right way to create them? Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Css Table Layouts

Hey everyone, the previous topic has inspired me to ask how do you create a good css table layout. I have tried over the years but tend to run into lots of issues since as soon as you start floating divs, things get complex and really hard to give good positioning. Plus, they tend to look different ...more

   30-Jan-2008    Reply         

Two Ways To Create A Dll .dll In V...

Note - I Used VB.net but I Think It Works The Same In Other Languages. Please Let Me Know If It Doesn't. Thanks Hi Everybody, This Tutuorial Was Created By Shadow_x21 (_x21) Part 1 - This Tutorial Will Show You How To: Create A Class Library [ Also Calle ...more

   02-Nov-2008    Reply         

Help With Css Sytelsheet

Just wanted to ask for some help with my site regarding CSS Stylesheet. If you go to my site and see that there is a menu list on the left hand side. I wanted to create another box under that one the same width. The contents of my CSS Stylesheet ...more

   31-Aug-2010    Reply         

Css- Review With Tutorial If u r learning CSS, learn it with me.   Css- Review With Tutorial If u r learning CSS, learn it with me. (2) (7) Problem With Menubar In IE  Problem With Menubar In IE