Till css2, we can buld two types of layouts, Fixed and Fluid. These layouts are classified as Fixed or Fluid on the basics of their width. Body width is always 100% of screen and depends on screen resolution, but layout width can be changed to fixed or fluidic. The most popular resolution for desktop is 1366*768.

CSS Layouts Types


CSS Layouts, Fixed Vs Fluid

CSS Fixed layouts are layouts with fixed width in px or em, exp 960px, 1200px, 1170px, etc.

CSS Fluid Layouts or Elastic layouts are layouts with width in percentage or auto.

Difference between fixed and Fluid layouts.

PropertyFixed LayoutLiquid Layout
Width of wrapIn Pixels ( 960px, 1200px).In Percentage or auto, for exp 80%
Heightin Pixels or auto.Automatic
Device CompatibilityFor devices greater than their width.Remain Same. Do not compress
Text Scrolling on various DevicesRemain sameText scroll down
Print FriendlyYesNo

Fixed Layout

Fixed Layout is a layout in which the width of main container is fixed ( in pixels). Popular Fixed width layouts are 1200px and 960px (used earlier).

Properties of Fixed Layout

  • Fixed width in pixels.
  • Text doesn't scroll down when browser windows in minimised.
  • Independent of screen size.
  • Horizontal Scroll will come when screen size is less than width of main container.

Fixed layout Example

<style>
*{
	margin:0px;
}
.wrap{ 
	width:960px;    
	margin:auto;    
}
.header{
	padding:10px;
	background:aqua;
}
.nav{
	height:50px;
	background:gray;
}
.container{
	background:white;
}
.aside{
	height:300px;
	background:pink;
	float:left;
}
.section{
	height:660px;
	background:yellow;
	float:left;
}
.footer{
	padding:10px;
	background:#333;
}
.clear{
	clear:both;
}
</style>
    <div class="wrap">
        <div class="header">This is header</div>
        
        <div class="nav">This is navigation menu</div>
        
        <div class="container">
            <div class="aside">this is left sidebar</div>
            <div class="section">this is right section</div>
            <div class="clear"></div>
        </div>
        
        <div class="footer">this is footer</div>
    </div>
</div>
Click here to see example of fixed Layout

Fluid or Elastic or Liquid Layout:

Liquid Layouts is a layout in which the width of main container is flexible( in percentage). Whatever the screen-size is, the layout will remain same.

Properties of Fluid Layout

  • Width is in percentage.
  • Text scroll down when zoom in or zoom out
  • Dependent of screen size.
  • Horizontal Scroll will Never come on any screen unless any fixed content is inside.

Fluid Layout Example

<style>
*{
    margin:0px;
}
.wrap{ 
    width:80%;       
    margin:auto;    
}
.header{
    padding:10px;
    background:aqua;
}
.nav{
    height:50px;
    background:gray;
}
.container{
    background:white;
}
.aside{
    width:25%;   
    background:pink;
    float:left;
}
.section{
    width:75%;   
    background:yellow;
    float:left;
}
.footer{
	padding:10px;
	background:#333;
}
.clear{
	clear:both;
}
</style>

<div class="wrap">
    <div class="header">This is header</div>
    
    <div class="nav">This is navigation menu</div>
    
    <div class="container">
        <div class="aside">this is left sidebar</div>
        <div class="section">this is right section</div>
        <div class="clear"></div>
        
    </div>
    <div class="footer">this is footer</div>
</div>
Click here to see example of Liquid Layout