当前位置:网站首页>Media query adaptation
Media query adaptation
2022-07-28 23:23:00 【Corner sheep】
List of articles
Media query
Media query : Based on one or more device types 、 Specific characteristics and environment to apply styles
1、 Media type
2、 Media features
3、 Logical operators
Media type
all All devices
print Printer devices
screen Colorful computer screen
speech Auditory equipment ( For people with visual impairment , A device that can present the content of a page in the form of voice )
Be careful :tty、tv、projection、handheld、braille、embossed、aural And other types of media queries 4 Has been abandoned
Media features
One 、width Width
- min-width Minimum width , The width can only be larger than this
- max-width Maximum width , The width can only be smaller than this
Two 、height Height
- min-height Minimum height , The height can only be larger than this
- max-height Maximum height , The height can only be smaller than this
3、 ... and 、orientation Direction
landscape Horizontal screen ( The width is greater than the height )
portrait Jianping ( The height is greater than the width )
aspect-ratio Width ratio
-webkit-device-pixel-ratio Pixel ratio (webkit Private properties of the kernel )
/* 400-500 Is the default */
div {
width: 100px;
height: 100px;
background: red;
}
/* The screen size is larger than 500 I'll be satisfied when I'm in */
@media (min-width: 500px) {
div {
background: green;
}
}
/* The screen size is smaller than 400 I'll be satisfied when I'm in */
@media (max-width: 400px) {
div {
background: blue;
}
}
/* When the screen is horizontal */
@media (orientation: landscape) {
div {
width: 400px;
height: 100px;
}
}
/* When the screen is vertical */
@media (orientation: portrait) {
div {
width: 100px;
height: 400px;
}
}
/* Is the aspect ratio 4:3 I'll be satisfied when I'm in ,800*600 The time is 4:3 */
@media (aspect-ratio: 4/3) {
div {
border: 10px solid #000;
}
}
/* When the pixel ratio is 2 When , Satisfy */
@media (-webkit-device-pixel-ratio: 2) {
div:after {
content: ' Chen Xuehui ';
font-size: 50px;
}
}
Logical operators : Used to make conditional judgment
and Merge multiple media queries ( And it means )
, Configure a media query ( Or it means )
not Negate the media query results
only Apply styles only after the media query matches successfully ( Guard against old browsers )
When the screen size meets several conditions at the same time , It's going to take the maximum 
div {
width: 200px;
height: 200px;
background: red;
}
/* The size ratio of the screen 700 When the screen is large and horizontal */
@media all and (min-width: 700px) and (orientation: landscape) {
div {
background: green;
}
}
/* Screen size ratio 800 Small , Or when the screen is horizontal */
@media (max-width: 800px), (orientation: landscape) {
div {
background: pink;
}
}
/* The size of the screen should be larger than 800 When , The whole is satisfied */
@media not all and (max-width: 800px) {
div {
background: blue;
}
}
@media only screen and (min-width: 1000px) {
div {
background: grey;
}
}
Media query application
div {
padding: 50px 0;
border: 1px solid #000800;
}
div:after {
content: ' This is a house ';
}
/* Less than 1000 Size is enough */
@media all and (max-width: 1000px) {
div {
background: green;
}
div:after {
content: ' wow , The house is so big , You can put down the pit ';
}
}
/* Less than 800 Be satisfied when */
@media all and (max-width: 800px) {
div {
background: khaki;
}
div:after {
content: ' oh , The house has become smaller , Only one double bed can be put ';
}
}
/* Size less than 500 Just be satisfied */
@media all and (max-width: 500px) {
div {
background: hotpink;
}
div:after {
content: ' Ah , The house is smaller , Only one single bed can be put down ';
}
}
/* Less than 300 I'll be satisfied when I'm in */
@media all and (max-width: 300px) {
div {
background: turquoise;
}
div:after {
content: ' Why , The house is too small , The bed can't fit ';
}
}
media Media query from mobile terminal to PC End to end adaptation
/* Less than 768 ipad*/
@media screen and (max-width: 768px) {
html {
font-size: 18px;
}
}
/* Less than 480px mobile phone */
@media screen and (max-width: 480px) {
html {
font-size: 16px;
}
}
/*768-1023*/
@media screen and (min-width: 769px) and (max-width: 1023px) {
html {
font-size: 20px;
}
}
/*1024-1279*/
@media screen and (min-width: 1024px) and (max-width: 1279px) {
html {
font-size: 24px;
}
}
/*1280-1440*/
@media screen and (min-width: 1280px) and (max-width: 1439px) {
html {
font-size: 26px;
}
}
/*>=1440 Device screen for */
@media screen and (min-width: 1440px) {
html {
font-size: 28px;
}
}
/*>=1920 Device screen for */
@media screen and (min-width: 1920px) {
html {
font-size: 34px;
}
}
/* PC End */
/* >=1920px */
@media (min-width: 1921px) {
html {
font-size: 30px;
}
}
@media (max-width: 1920px) {
html {
font-size: 26px;
}
}
@media (max-width: 1600px) {
html {
font-size: 24px;
}
}
@media (max-width: 1440px) {
html {
font-size: 22px;
}
}
@media (max-width: 1280px) {
html {
font-size: 20px;
}
}
@media (max-width: 1024px) {
html {
font-size: 18px;
}
}
/* Mobile */
@media (max-width: 999px) {
html {
font-size: 20px;
}
}
@media (max-width: 759px) {
html {
font-size: 20px;
}
}
@media (max-width: 376px) {
html {
font-size: 20px;
}
}
@media screen and (min-width: 1441px) {
}
@media screen and (min-width: 1510px) {
}
@media screen and (min-width: 1600px) {
}
@media screen and (min-width: 1680px) {
}
@media screen and (min-width: 1920px) {
}
@media screen and (max-width: 1280px) {
}
// Mobile terminal
@media screen and (max-width: 900px) {
}
@media screen and (max-width: 320px) {
}
边栏推荐
- Inheritance in swift
- Solve the exception that all control files are damaged
- cnpm安装步骤
- 6 个超级良心的开源教程!
- frontiers出版社投稿记录(附状态变化)
- 终端输出g_debug()信息
- Seagate released a new risc-v architecture processor: the performance of mechanical hard disk soared 3 times
- 18张图,直观理解神经网络、流形和拓扑
- 【C语言】三子棋小游戏实现
- Rouyi cloud platform - how to realize the launch and login functions of the project and how to create new modules
猜你喜欢

Cglib create proxy

RouYi-Cloud平台 ---项目的启动、登录功能是怎么实现的、怎么样创建新模块

There are four ways for Nacos to configure hot updates and multiple ways to read project configuration files, @value, @refreshscope, @nacosconfigurationproperties

The Gerrit local code is associated to the remote warehouse

如何在VR全景中嵌入AI数字人功能?打造云端体验感

Sqlilabs-1 (breakthrough record)

Introduction to address book export without code development platform

【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码

【MySQL系列】 MySQL表的增删改查(进阶)

行泊ADAS摄像头前装搭载同比增长54.15%,TOP10供应商领跑
随机推荐
Submission records of frontiers Publishing House (with status changes)
Performance optimized APK slimming
如何在VR全景中嵌入AI数字人功能?打造云端体验感
18 diagrams, intuitive understanding of neural networks, manifolds and topologies
View APK signature
Research on cookies in WebView
《MySQL数据库进阶实战》读后感(SQL 小虚竹)
MySQL foundation - advanced functions
Apk signature.Apk version information
[MySQL series] addition, deletion, modification and query of MySQL tables (Advanced)
recursion and iteration
WebView optimization
High quality subroutine 1
This year, MediaTek 5g chip shipments are expected to reach 50million sets!
Empowering Chinese core entrepreneurs! See how Moore elite solves the development problems of small and medium-sized chip Enterprises
Advanced C language: pointer (2)
The industry's first cloud native security detection dual model! Safety dog heavyweight report appears at the digital China Construction Summit
CGLIb 创建代理
Introduction to address book export without code development platform
ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([