Using CSS3 to implement a simple responsive layout (code)

Source: Internet
Author: User

This article simply explains how to use CSS3 to implement a simple responsive layout:

CSS3 File:

*{margin:0px; padding:0px;}. heading,.container,.footing{margin:10px Auto;}.    heading{height:100px; background-color:red;}.    left,.right,.main{height:300px; Background-color:yellow;}.    footing{height:100px; Background-color:gray;} <!--media= "only screens and max-width:640px" means that this style sheet is used only when the width of the rendering screen is no more than 640px---@media    min-width:960px) {. Heading,. Container,. footing{width:960px;        }. Left,. Main,. right{float:left;    height:500px;    }. Left,. right{width:200px;        }. main{margin:0px 5px;    width:550px;    }. container{height:500px; }} @media screen and (min-width:600px) and (max-width:960px) {. Heading,. Container,. footing{width:600p    X        }. Left,. main{Float:left;    height:400px;    }. right{Display:none;    }. left{width:160px;        }. main{width:435px; Margin-left:5px;    }. container{height:400px;    }} @media screen and (max-width:600px) {. Heading,. Container,. footing{width:400px;        }. Left,. right{width:400px;    height:100px;        }. main{margin-top:10px;        width:400px;    height:200px;    }. right{margin-top:10px;    }. container{height:420px; }}

HTML5 file:

<! DOCTYPE html>

The code of this article can implement the same interface and display different layouts under different width of the rendering width.

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.