当前位置:网站首页>判断横竖屏的最佳实现
判断横竖屏的最佳实现
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);
边栏推荐
- 当用户登录,经常会有实时的下拉框,例如,输入邮箱,将会@qq.com,@163.com,@sohu.com
- 获取前一天的js(时间戳转换)
- Norgen AAV extractant box instructions (including features)
- Codeforces Round #804 (Div. 2) - A, B, C
- Abbkine trakine F-actin Staining Kit (green fluorescence) scheme
- How to open an account online for futures? Is it safe?
- Clear app data and get Icon
- Applet page navigation
- Duchefa丨S0188盐酸大观霉素五水合物中英文说明书
- 当Steam教育进入个性化信息技术课程
猜你喜欢

phpstudy小皮的mysql点击启动后迅速闪退,已解决

Norgen AAV提取剂盒说明书(含特色)

研学旅游实践教育的开展助力文旅产业发展

Duchefa细胞分裂素丨二氢玉米素 (DHZ)说明书

Abnova丨E (DIII) (WNV) 重组蛋白 中英文说明书

渗透创客精神文化转化的创客教育

Interpreting the daily application functions of cooperative robots

Cutting edge technology for cultivating robot education creativity

MySQL InnoDB架构原理

基于flask写一个接口
随机推荐
bazel是否有学习的必要
产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
解析五育融合之下的steam教育模式
解读协作型机器人的日常应用功能
Abnova maxpab mouse derived polyclonal antibody solution
Graph embedding learning notes
E. Singhal and numbers (prime factor decomposition)
PHP反序列化+MD5碰撞
ProSci LAG-3 重组蛋白说明书
Where is a good stock account? Is online account manager safe to open an account
leetcode:1755. 最接近目标值的子序列和
序列联配Sequence Alignment
Duchefa s0188 Chinese and English instructions of spectinomycin hydrochloride pentahydrate
Abnova丨E (DIII) (WNV) 重组蛋白 中英文说明书
The development of research tourism practical education helps the development of cultural tourism industry
Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
获取前一天的js(时间戳转换)
Which is the best online collaboration product? Microsoft loop, notion, flowus
Common view container class components