Skip to content

Commit 8958465

Browse files
author
zhangyonghong
committed
update
1 parent 4846e84 commit 8958465

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

css.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,27 @@ user-select:none;
311311
<!--移动web页面自动探测电话号码-->
312312
<meta name="format-detection" content="telephone=no">
313313
<meta http-equiv="x-rim-auto-match" content="none">
314+
```
315+
316+
- [CSS判断横屏竖屏](http://www.w3cways.com/1772.html)
317+
```css
318+
@media screen and (orientation: portrait) {
319+
/*竖屏 css*/
320+
}
321+
@media screen and (orientation: landscape) {
322+
/*横屏 css*/
323+
}
324+
```
325+
326+
```javascript
327+
//判断手机横竖屏状态:
328+
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
329+
if (window.orientation === 180 || window.orientation === 0) {
330+
alert('竖屏状态!');
331+
}
332+
if (window.orientation === 90 || window.orientation === -90 ){
333+
alert('横屏状态!');
334+
}
335+
}, false);
336+
//移动端的浏览器一般都支持window.orientation这个参数,通过这个参数可以判断出手机是处在横屏还是竖屏状态。
314337
```

0 commit comments

Comments
 (0)