Using div with different height to create layout : div layout « Tags « HTML / CSS






Using div with different height to create layout

      
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>CSS Positioning Example</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type='text/css'>
/* CSS Document */

body {
  background-color:#efefef;
  font-family:arial, verdana, sans-serif;}

div {
  width:800px;
  border:1px solid #000000;
  margin:1px;
  padding:5px;}

div#masthead {
  height:100px;
  background-color:#d6d6d6;}

div#navigation {
  height:40px;
  background-color:#666666; 
  color:#ffffff;}

div#body {
  height:100%;
  background-color:#ffffff;}
</style>


</head>

<body>
  <div id="masthead"><h1>Masthead</h1></div>
  <div id="navigation">
    <span class="navItem">Navigation item 1</span> | 
    <span class="navItem">Navigation item 2</span> | 
    <span class="navItem">Navigation item 3</span> | 
    <span class="navItem">Navigation item 4</span>
  </div>
  <div id="body"><h1>Headline</h1><p>Article goes here</p></div>
</body>

</html>

   
    
    
    
    
    
  








Related examples in the same category

1.div float: left;
2.div float: left; 2
3.Two floating right div section
4.Two floating left div sections
5.Div float: none;
6.Div float: left; 3
7.Div float: left; 4
8.Div float: left; 5
9.DIV float: left; 6
10.DIV float: right;
11.div float with width and height
12.div width: 50px;
13.DIV width: auto;
14.Div width: 100%;
15.Div width: 1001px;
16.Div width: 500px;
17.DIV width: 134px;
18.Using width to control nested div boxes
19.Set width and height to DIV
20.Shrinkwrapped DIV by setting both width and height to auto
21.div height: 50px;
22.Div line-height: 23px;
23.Div line-height: 17px;
24.DIV line-height: 1.3em;
25.DIV height:1.8em;
26.DIV line-height:1.8em;
27.Div for clearing
28.Div clear: both;
29.DIV for clear
30.DIV clear: left;
31.Div position: relative;
32.DIV position: absolute;
33.Using position: fixed; to place div tags to four corners
34.Using position: absolute; to place div tags to four corner
35.div with position: absolute; inside div with position: relative;
36.div with position: absolute; inside body
37.div position:relative;
38.Set position of DIV to absolute, to bottom 50px, to left 100px
39.Wrap tags in DIV and set the position
40.Div left: 0;
41.Div display: inline;
42.div display: table-cell;
43.Div top: 0;