._简述媒体查询外联式的基本语法是什么">
赞
踩
- <!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>Document</title>
- <style>
- /*
- 视口宽度 >= 768px,网页背景色是 粉色
- 视口宽度 >= 992px,网页背景色是 绿色
- 视口宽度 >= 1200px,网页背景色是 skyblue
- */
-
- /* css属性都有层叠性 */
-
- /* @media (min-width: 1200px) {
- body {
- background-color: skyblue;
- }
- } */
-
- @media (min-width: 768px) {
- body {
- background-color: pink;
- }
- }
- @media (min-width: 992px) {
- body {
- background-color: green;
- }
- }
- @media (min-width: 1200px) {
- body {
- background-color: skyblue;
- }
- }
-
- </style>
- </head>
- <body>
-
- </body>
- </html>
-
- 媒体查询-link标签
-
- <!-- 视口宽度 >= 992px,网页背景色为粉色 -->
- <!-- 视口宽度 >= 1200px,网页背景色为绿色 --> media 必须加小括号 否则不生效
- <link rel="stylesheet" href="./one.css" media="(min-width: 992px)">
- <link rel="stylesheet" href="./two.css" media="(min-width: 1200px)">
- 检测到视口宽度小于768px, 认为是手机端, left隐藏
- <!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>检测到视口宽度小于768px, 认为是手机端, left隐藏</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
-
- .box {
- display: flex;
- width: 100%;
- }
-
- .left {
- width: 300px;
- min-height: 500px;
- background-color: pink;
- }
-
- .main {
- flex: 1;
- min-height: 500px;
- background-color: skyblue;
- }
-
- /* 如果检测到视口宽度小于768px, 认为是手机端, left隐藏 */
- @media (max-width: 768px) {
- .left {
- display: none;
- }
- }
- </style>
- </head>
- <body>
- <div class="box">
- <div class="left">left</div>
- <div class="main">响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果响应式网页效果</div>
- </div>
- </body>
- </html>
- link标签引入,class 类名调用
-
- <link rel="stylesheet" href="./bootstrap-3.4.1-dist/css/bootstrap.min.css">
- <style>
- div {
- height: 50px;
- background-color: pink;
- }
- </style>
-
-
- <div class="container">1</div>
- <!-- 栅格系统默认将网页分成12份 -->
- <!-- 需求: 大屏: 一行排列4个内容; 中屏:一行排列2个内容 -->
- <div class="container">
- <div class="col-lg-3 col-md-6">1</div>
- <div class="col-lg-3 col-md-6">2</div>
- <div class="col-lg-3 col-md-6">3</div>
- <div class="col-lg-3 col-md-6">4</div>
- </div>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。