CSS example of using table to implement five common layouts _css tutorial _css_ Web Authoring

Source: Internet
Author: User
This article mainly introduces the CSS using table to achieve five common layout of the method example of the relevant information, small series feel very good, now share to everyone, there is CSS source, oh, also for everyone to do a reference. The little friends who are interested in CSS come along and look at it.

This article describes the CSS using table to implement five common layout methods examples, share to everyone, specifically as follows:

Layout one:

Effect:

Code:

Html:


<p class= "header" >header</p><p class= "main" >main</p><p class= "Footer" >footer</p >


Note: P must have content, otherwise it will not show

Css:


body{  margin:0;  padding:0;  width:100%;  MIN-HEIGHT:100VH;  display:table;  Text-align:center;}. header,.main,.footer{  Display:table-row;}. header{  height:50px;  Background:tomato;}. main{  Background:skyblue;}. footer{  height:50px;  Background: #9d70ff;}


Layout two:

Effect:

Code:

Html:


<p class= "header" >header</p><p class= "main" >  <p class= "left" >left</p>  <p Class= "right" >right</p></p><p class= "Footer" >footer</p>


Css:


body{  margin:0;  padding:0;  width:100%;  MIN-HEIGHT:100VH;  display:table;  Text-align:center;}. header,.main,.footer{  Display:table-row;}. header{  height:50px;  Background:tomato;}. main{  width:100%;  display:table;  Height:calc (100vh-100px);}. Main. left{  width:300px;  Display:table-cell;  Background: #fcea96;}. Main. right{  Display:table-cell;  Background:skyblue;}. footer{  height:50px;  Background: #9d70ff;}


Note: 100px in the Height property of main is the sum of the header and footer heights

Layout three:

Effect:

Code:

Html:


<p class= "left" >left</p><p class= "right" >  <p class= "header" >header</p>  <p class= "main" >main</p>  <p class= "Footer" >footer</p></p>


Css:


body{  margin:0;  padding:0;  MIN-HEIGHT:100VH;  display:table;  Text-align:center;}. left{  Display:table-cell;  width:200px;  Background:tomato;}. right{  display:table;  Width:calc (100vw-200px);  HEIGHT:100VH;}. header,.main,.footer{  Display:table-row;}. header{  height:50px;  Background:skyblue;}. main{  background: #fcea96;}. footer{  height:50px;  Background: #9d70ff;}


Layout four (double column layout, example for left fixed, right adaptive):

Effect:

Code:

Html:


<p class= "left" >left</p><p class= "right" >right</p>


Css:


body{  margin:0;  padding:0;  width:100%;  HEIGHT:100VH;  display:table;  Text-align:center;}. left,.right{  Display:table-cell;}. left{  width:300px;  Background:tomato;}. right{  Background:skyblue;}


Layout Five (three-column layout, example for left fixed, right fixed, intermediate adaptive):

Effect:

Code:

Html:


<p class= "left" >left</p><p class= "Middle" >middle</p><p class= "right" >right</p >


Css:


body{  margin:0;  padding:0;  width:100%;  HEIGHT:100VH;  display:table;  Text-align:center;}. left,.middle,.right{  Display:table-cell;}. left{  width:300px;  Background:tomato;}. middle{  background: #ffe69e;}. right{  width:200px;  Background:skyblue;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.