响应式布局
------------恢复内容开始------------
响应式布局就是手机端,电脑端,不管尺寸的大小,页面都能正常显示
------------恢复内容结束------------
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | <! 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 > |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现