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)
Table of contents Preface Two-dimensional array, ...
To do a paginated query: 1. For MySQL, it is not ...
What is the nobody user in Unix/Linux systems? 1....
VMware vSphere is the industry's leading and ...
1. Create a new UI project First of all, our UI i...
Beginners can learn HTML by understanding some HT...
location / { index index.jsp; proxy_next_upstream...
The google.html interface is as shown in the figur...
Related system calls for file operations create i...
1 MySQL autocommit settings MySQL automatically c...
1. Compatibility As shown below: The compatibilit...
When Docker creates a container, it uses the brid...
Table of contents 1. Basic usage and logic 2. Fea...
Website, (100-1)% of the content is navigation 1....
Table of contents 1. What is a calculated propert...