当前位置:网站首页>Responsive - media query
Responsive - media query
2022-07-04 06:41:00 【HHppGo】
Last one bilibili Summary of problems on the page :
Element display level :
Standard flow < float < location
Standard flow The element of is on the page At the bottom
location The element of is on the page At the top
Be careful :header Fixed positioning , At the top ;
The reason for the penetration effect , Because header No background color is set
Locate the display level of the element :
- The positioned elements are displayed at the same level
- however ,HTML The level of positioning elements written in the back is higher than that in the front
- Can be in The style of the previous element Add
z-index: 1;
Make it higher than the later ( As long as the number is greater than 0 that will do )
Media query - Basic grammar
Code :
<!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> /* Viewport width is less than or equal to 768px, The background color of the web page is pink */ @media (max-width: 768px) {
body {
background-color: pink; } } /* Viewport width is greater than or equal to 1200px, The background color of the web page is skyblue */ @media (min-width: 1200px) {
body {
background-color: skyblue; } } </style>
</head>
<body>
</body>
</html>
Media query - Writing order
Code :
<!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> /* Viewport width >= 768px, The background color of the web page is Pink Viewport width >= 992px, The background color of the web page is green Viewport width >= 1200px, The background color of the web page is skyblue */ /* Tips : Code specification mid-width: From small to capital max-width: From large to small */ /* The code is not standardized , Girlfriend two lines of tears ~~( It needs to be changed Bug, No time to accompany ) */ @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>
Media query -link introduce
one.css It's about >=992px The style of
two.css It's about >=1200px The style of
<!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>
<!-- Viewport width >= 992px, The background color of the web page is pink one.css-->
<link rel="stylesheet" href="./one.css" media="(min-width:992px)">
<!-- Viewport width >= 1200px, The background color of the web page is green two.css-->
<link rel="stylesheet" href="./two.css" media="(min-width:1200px)">
</head>
<body>
</body>
</html>
Media query - hide
<!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> * {
margin: 0; padding: 0; } .box {
/* 1.flex Layout */ display: flex; width: 100%; } .left {
width: 300px; min-height: 500px; background-color: pink; } .main {
/* 2. Elastic expansion ratio : Guarantee left have 300px Width */ flex: 1; min-height: 500px; background-color: skyblue; } /* 3. Viewport width <= 992px, hide .left */ @media (max-width:992px) {
.left {
display: none; } } /* visibility: hidden; Hidden elements : Space occupying and hiding ( Hidden elements still occupy positions ) display:none; Hidden elements : Non occupying hiding ( frequently-used ) */ </style>
</head>
<body>
<div class="box">
<div class="left">left</div>
<div class="main">
Responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive Responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive Responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect responsive web page effect
</div>
</div>
</body>
</html>
边栏推荐
- [MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)
- [March 3, 2019] MAC starts redis
- MySQL 45 lecture learning notes (VII) line lock
- 金盾视频播放器拦截的软件关键词和进程信息
- Bicolor case
- Arcpy uses the updatelayer function to change the symbol system of the layer
- 【问题记录】03 连接MySQL数据库提示:1040 Too many connections
- The sorting in C language realizes the number sorting method from small to large
- 同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
- Selection (022) - what is the output of the following code?
猜你喜欢
Another company raised the price of SAIC Roewe new energy products from March 1
regular expression
雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
Tree DP
Download kicad on Alibaba cloud image station
17-18. Dependency scope and life cycle plug-ins
Overview of convolutional neural network structure optimization
Common usage of time library
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
Fundamentals of SQL database operation
随机推荐
STM32 单片机ADC 电压计算
How does the recv of TCP socket receive messages of specified length?
Arcpy 利用updatelayer函数改变图层的符号系统
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
SQL join, left join, right join usage
颈椎、脚气
What is Gibson's law?
What is the sheji principle?
[March 3, 2019] MAC starts redis
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
MySQL 45 lecture learning notes (12) MySQL will "shake" for a while
Another company raised the price of SAIC Roewe new energy products from March 1
Redis面试题集
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
selenium IDE插件下载安装使用教程
centos8安装mysql.7 无法开机启动
Mysql 45讲学习笔记(六)全局锁
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
Software keywords and process information intercepted by Golden Shield video player
Uniapp custom environment variables