Preface There are many devices nowadays, including PC, iPad, mobile phone, smart watch and smart TV. If there is no responsive layout, then the computer web page will be displayed on a mobile phone or iPad, the experience will be very poor, the operation will be inconvenient, and the visual fatigue will occur. Therefore, we must have a responsive layout when developing web pages. index <!DOCTYPE html> <html> <head> <title>Responsive Layout</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="content"> <div id="header">Header</div> <div id="left">Left side</div> <div id="center">Middle</div> <div id="right">Right side</div> <div id="footer">Bottom</div> </div> </body> </html> CSS *{ margin: 0; padding: 0; } /*Adapt to PC width greater than 1000px*/ @media screen and (min-width: 1000px) { #content{ width: 960px; margin:0 auto; } #header{ width: 100%; line-height: 100px; float: left; background: #333; color: #fff; text-align: center; font-size: 30px; margin-bottom: 10px; } #left{ width: 200px; line-height: 400px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; margin-right: 10px; } #center{ width: 540px; line-height: 400px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; } #right{ width: 200px; line-height: 400px; text-align: center; background: #333; float: right; font-size: 30px; color: #fff; } #footer{ width: 960px; height: 200px; background: #333; color: #fff; line-height: 200px; font-size: 30px; text-align: center; float: left; margin-top: 10px; } } /*Adapt to pad width between 640-1000*/ @media screen and (min-width: 640px) and (max-width: 1000px) { #content{ width: 600px; margin:0 auto; } #header{ width: 100%; line-height: 100px; float: left; background: #333; color: #fff; text-align: center; font-size: 30px; margin-bottom: 10px; } #left{ width: 200px; line-height: 400px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; margin-right: 10px; } #center{ width: 390px; line-height: 400px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; } #right{ width: 600px; line-height: 300px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; margin-top: 10px; } #footer{ width: 600px; height: 200px; background: #333; color: #fff; line-height: 200px; font-size: 30px; text-align: center; float: left; margin-top: 10px; } } /*Adapt to mobile terminal width less than 640*/ @media screen and (max-width: 639px) { #content{ width: 400px; margin:0 auto; } #header{ width: 100%; line-height: 100px; float: left; background: #333; color: #fff; text-align: center; font-size: 30px; margin-bottom: 10px; } #left{ width: 100%; line-height: 150px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; margin-bottom: 10px; } #center{ width: 100%; line-height: 300px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; } #right{ width: 100%; line-height: 150px; text-align: center; background: #333; float: left; font-size: 30px; color: #fff; margin-top: 10px; } #footer{ width: 100%; height: 200px; background: #333; color: #fff; line-height: 200px; font-size: 30px; text-align: center; float: left; margin-top: 10px; } } Use @media screen and (limited scope) to control the layout of the web page, for example min-width represents the minimum limit, and max-width represents the maximum limit. PC Pad end Phone The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: WeChat Mini Programs Implement Star Rating
>>: Font selection problem of copyright symbol in Html (how to make copyright symbol more beautiful)
environment Host IP 192.168.0.9 Docker version 19...
Table of contents Preface 1. unknown vs any 2. Th...
Method 1: <input id= "File1" type= &q...
mysqladmin is an official mysql client program th...
K8s k8s is a cluster. There are multiple Namespac...
The Meta tag is an auxiliary tag in the head area...
Cooper talked about the user's visual path, w...
Zabbix deployment documentation After zabbix is ...
Table of contents 1. Component Registration 1.1 G...
mycli MyCLI is a command line interface for MySQL...
Table of contents Project Background start Create...
When we perform automatic discovery, there is alw...
Introduction: Sometimes, in order to develop a pr...
This article uses examples to illustrate the impl...
one. Remote deployment using tomcat 1.1 Problems ...