国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - Trying to determine the media query of css through js. Error
習(xí)慣沉默
習(xí)慣沉默 2017-07-05 10:38:16
0
3
935
@media screen and (min-width: 360px) and (max-width: 375px){
    .ejiao_description .form form p{
        margin-bottom: 11px;
    }
}

The media query in css is written like this
js

var screen1 = window.matchMedia('@media  (min-width: 360px) and (max-width: 375px)');
    if (screen1.matches){
        XXXXXX.....
    }
    else{
        XXXX....
    }

But it doesn’t work now. What’s wrong?

習(xí)慣沉默
習(xí)慣沉默

reply all(3)
滿天的星座
https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia

Please see the documentation

我想大聲告訴你
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        @media screen and (min-width: 360px) and (max-width: 375px){
            .aa .form form p{
                margin-bottom: 11px;
            }
        }
    </style>
</head>
<body>
<!-- 想通過(guò)js判斷css的媒體查詢 出錯(cuò) -->
<p class="aa">
    <p class="form">
        <form>
            <p>123123</p>
        </form>
    </p>
</p>
</body>
<script>
    var screen1 = window.matchMedia('(min-width: 360px) and (max-width: 375px)');
    console.log( screen1 );
    if (screen1.matches){
        console.log( 1 );
    }
    else{
        console.log( 2 );
    }
</script>
</html>

is window.matchMedia('(min-width: 360px) and (max-width: 375px)');, no @media

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template