HTML5--use CSS3 for simple responsive layouts

Source: Internet
Author: User

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

HTML5 file:

<! DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name ="viewport" content="width = device-width, Initial-scale=1 ">    <title>index01</title>    <link href="style01.css" type="text/css" rel=" Stylesheet "></head><body>    <div class="heading"></div>    <div class="container">        <div class="Left"></div>        <div class="main"></div>        <div class="Right"></div>    </div>    <div class="footing"></div></body></html>

CSS3 File:

*{margin:0Px;Padding0Px;}. Heading,. Container,. Footing{margin:TenPX Auto;}. Heading{Height: -Px;Background-color:red;}. Left,. Right,. Main{Height: -Px;Background-color:yellow;}. Footing{Height: -Px;Background-color:gray;}<!--media="Only screen and (max-width:640px)"As long as the width of the rendering screen is not greater than640PX When you use this style sheet--@media screen and(Min-width:960PX) {. Heading,. Container,. Footing{width:960Px;}. Left,. Main,. Right{Float:left;Height -Px;}. Left,. Right{width: $Px;}. Main{margin:0Px5Px;Width550Px;}. Container{Height: -Px;}} @media Screen and(Min-width: -px and(Max-width:960PX) {. Heading,. Container,. Footing{width: -Px;}. Left,. Main{Float:left;Height -Px;}. Right{Display:none;}. Left{width: thePx;}. Main{width:435Px;Margin-left:5Px;}. Container{Height: -Px;}} @media Screen and(Max-width: -PX) {. Heading,. Container,. Footing{width: -Px;}. Left,. Right{width: -Px;Height -Px;}. Main{margin-top:TenPx;Width -Px;Height $Px;}. Right{margin-top:TenPx;}. Container{Height:420Px;}}

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

HTML5--use CSS3 for simple responsive layouts

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.