1.内联样式
2.外联样式
<
!
--
竖屏
--
>
<
link
rel
=
"stylesheet"
media
=
"all and (orientation:portrait)"
href
=
"..."
/
>
<
!
--
横屏
--
>
<
link
rel
=
"stylesheet"
media
=
"all and (orientation:landscape)"
href
=
"..."
/
>
1
2
3
4
5
6
7
8
9
10
|
var
mql
=
window
.
matchMedia
(
"(orientation: portrait)"
)
;
function
onMatchMeidaChange
(
mql
)
{
if
(
mql
.
matches
)
{
// 竖屏
}
else
{
// 横屏
}
}
onMatchMeidaChange
(
mql
)
;
mql
.
addListener
(
onMatchMeidaChange
)
;
|
1
2
3
4
5
6
7
8
9
10
|
var
mql
=
window
.
matchMedia
(
"(orientation: portrait)"
)
;
function
onMatchMeidaChange
(
mql
)
{
if
(
mql
.
matches
)
{
// 竖屏
}
else
{
// 横屏
}
}
onMatchMeidaChange
(
mql
)
;
mql
.
addListener
(
onMatchMeidaChange
)
;
|