响应式布局
2022/3/25 23:27:09
本文主要是介绍响应式布局,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
------------恢复内容开始------------
响应式布局就是手机端,电脑端,不管尺寸的大小,页面都能正常显示
------------恢复内容结束------------
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Media Queries</title> <style> body { font-family: Arial, Helvetica, sans-serif; background: gray; color: white; text-align: center; padding-top: 100px; } h1 { display: none; } /* samrtphone */ /* 媒体查询 */ @media(max-width:500px) { /* 当所用设备的宽超过500px样式不改变 当所用设备的宽不超过500px时 默认为手机端 */ body { background: red; } #samrtphone h1 { display: block; } } /* table */ /* 媒体查询 */ @media (min-width: 501px) and (max-width:768px) { /* 当所用设备的宽超过500px样式不改变 当所用设备的宽不超过500px时 默认为手机端 */ body { background: blue; } #table h1 { display: block; } } /* normal */ /* 媒体查询 */ @media (min-width: 769px) and (max-width:1200px) { /* 当所用设备的宽超过500px样式不改变 当所用设备的宽不超过500px时 默认为手机端 */ body { background: greenyellow; } #normal h1 { display: block; } } /* widescreen */ /* 媒体查询 */ @media screen and (min-width: 1201px) { /* 当所用设备的宽超过500px样式不改变 当所用设备的宽不超过500px时 默认为手机端 */ body { background: black; } #widescreen h1 { display: block; } } /* landscape */ /* 媒体查询 */ @media screen and (max-height: 500px) { /* 当所用设备的宽超过500px样式不改变 当所用设备的宽不超过500px时 默认为手机端 */ body { background: orange; } #landscape h1 { display: block; } } </style> <link rel="stylesheet" media="screen and (max-width:768px;)" href="css/new_file.css"> </head> <body> <div id="widescreen"> <h1>Widescreen</h1> </div> <div id="normal"> <h1>normal</h1> </div> <div id="table"> <h1>Table</h1> </div> <div id="samrtphone"> <h1>Samrtphone</h1> </div> <div id="landscape"> <h1>Landscape</h1> </div> </body> </html>
这篇关于响应式布局的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28微服务架构中API版本控制的实践
- 2024-09-28AI给的和自己写的Python代码,都无法改变输入框的内容,替换也不行
- 2024-09-27Sentinel配置限流资料:新手入门教程
- 2024-09-27Sentinel配置限流资料详解
- 2024-09-27Sentinel限流资料:新手入门教程
- 2024-09-26Sentinel限流资料入门详解
- 2024-09-26Springboot框架资料:初学者入门教程
- 2024-09-26Springboot框架资料详解:新手入门教程
- 2024-09-26Springboot企业级开发资料:新手入门指南
- 2024-09-26SpringBoot企业级开发资料新手指南