当前位置:网站首页>判断横竖屏的最佳实现
判断横竖屏的最佳实现
2022-07-05 20:50:00 【带脑子的CV工程师】
1、CSS Media Queries
1.内联样式
@media screen and (orientation:portrait) {
//竖屏
}
@media screen and (orientation:landscape) {
//横屏
}
2.外联样式
<!-- 竖屏 -->
<link rel="stylesheet" media="all and (orientation:portrait)" href="..." />
<!-- 横屏 -->
<link rel="stylesheet" media="all and (orientation:landscape)" href="..." />
3.window.matchMedia()
var mql = window.matchMedia("(orientation: portrait)");
function onMatchMeidaChange(mql){
if(mql.matches) {
// 竖屏
}else {
// 横屏
}
}
onMatchMeidaChange(mql);
mql.addListener(onMatchMeidaChange);
4.window.innerHeight/window.innerWidth
function detectOrient(){
if(window.innerHeight >= window.innerWidth) {
// 竖屏
}else {
// 横屏
}
}
detectOrient();
window.addEventListener('resize',detectOrient);
边栏推荐
- Redis唯一ID生成器的实现
- Abnova丨 MaxPab 小鼠源多克隆抗体解决方案
- Abnova total RNA Purification Kit for cultured cells Chinese and English instructions
- 教你自己训练的pytorch模型转caffe(二)
- Abbkine trakine F-actin Staining Kit (green fluorescence) scheme
- How to renew NPDP? Here comes the operation guide!
- 解析五育融合之下的steam教育模式
- Monorepo management methodology and dependency security
- 珍爱网微服务底层框架演进从开源组件封装到自研
- Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
猜你喜欢

Duchefa丨低熔点琼脂糖 PPC中英文说明书

Chemical properties and application instructions of prosci Lag3 antibody

教你自己训练的pytorch模型转caffe(三)

Abnova DNA marker high quality control test program

研學旅遊實踐教育的開展助力文旅產業發展

Abbkine BCA法 蛋白质定量试剂盒说明书

Specification of protein quantitative kit for abbkine BCA method

Analysis of steam education mode under the integration of five Education

Welcome to the game and win rich bonuses: Code Golf Challenge officially launched

IC popular science article: those things about Eco
随机推荐
2. < tag hash table, string> supplement: Sword finger offer 50 The first character DBC that appears only once
基于flask写一个接口
表单文本框的使用(二) 输入过滤(合成事件)
Monorepo管理方法论和依赖安全
基於flask寫一個接口
PHP deserialization +md5 collision
ViewRootImpl和WindowManagerService笔记
Abnova fluorescent dye 620-m streptavidin scheme
leetcode:1755. 最接近目标值的子序列和
Which is the best online collaboration product? Microsoft loop, notion, flowus
Nprogress plug-in progress bar
Abnova丨培养细胞总 RNA 纯化试剂盒中英文说明书
Abnova丨 MaxPab 小鼠源多克隆抗体解决方案
Simple understanding of interpolation search
Clear app data and get Icon
Is it safe to open a stock account by mobile phone? My home is relatively remote. Is there a better way to open an account?
Typhoon is coming! How to prevent typhoons on construction sites!
Composition of applet code
基于AVFoundation实现视频录制的两种方式
Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved