Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2010, 05:44 PM   PM User | #1
RedLars
New Coder

 
Join Date: Dec 2010
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
RedLars is an unknown quantity at this point
vertical strech

Hello,

I am using this html page to test some css styles.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
  <HEAD>
    <title></title>
    <LINK href="default.css" rel="stylesheet" type="text/css">
  </HEAD>
  <BODY>
    <div class="wrapper">
      TEST
    </div>
  </BODY>
</HTML>
To strech the page vertically this works in firefox atleast
Code:
.wrapper
{
  height:100%;
  width:650px;
  margin-left:auto;
  margin-right:auto;
  border-style:solid;
  border-width:1px;
  border-color:black;
}

html, body {
  height:100%;
 }
Why do I need to set height equal 100% for three different elements (html, body and wrapper) ? Just would like to understand what is happening.
RedLars is offline   Reply With Quote
Old 12-13-2010, 05:52 PM   PM User | #2
NoeG
Regular Coder

 
Join Date: Oct 2010
Location: San Antonio Tx
Posts: 251
Thanks: 12
Thanked 11 Times in 11 Posts
NoeG is an unknown quantity at this point
you should change the class=wrapper to id=wrapper and then .wrapper to #wrapper in your html you dont have to but its better because your not going to need another wrapper with the same styles again..thats the diference between class and id

and also you could just take out the height:100% if you want the wrapper to expand as you add to it..

the .wrapper just targets your div class=wrapper not anything else but you set the height to 100% so it takes up the entire height of your body
NoeG is offline   Reply With Quote
Old 12-13-2010, 06:06 PM   PM User | #3
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello RedLars,
Think of the HTML elements as tranparent pages that you are stacking in layers. <html> is the first layer, <body> the second and your .wrapper the third.

Use an example like this and watch what happens when you remove the height: 100%; from any one of those layered elements -
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html {
	height: 100%;
	background: #FC6;
}
body {height: 100%;}
#container {
	height: 100%;
	width: 650px;
	margin: 0 auto;
	border: 1px solid #000;
}
</style>
</head>
<body>
    <div id="container">
    <!--end container--></div>
</body>
</html>
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-14-2010, 08:17 PM   PM User | #4
RedLars
New Coder

 
Join Date: Dec 2010
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
RedLars is an unknown quantity at this point
Thanks for the feedback. The analogy of stacked pages was good.
RedLars is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:46 AM.


Advertisement
Log in to turn off these ads.