媒体查询无响应

media query non responsive

好的,我已经有一段时间没有使用媒体查询了,但我相信我做对了。 我没有使用 sass 或更少只是普通的旧 css.

.btn-test {
    border-radius: 2px;
    border: 1px solid #2e70a4;
    color: #fff;
    font-size: 12px;
    background: #2c83c9;
    position: relative;
    transition: all .2s ease;
    display: inline-block;
    text-decoration: none;
    margin: 18px 9px 0 0;
    padding: 5px 9px 0 9px;
    height: 37px;
    line-height: 16px;
    text-align: center;
}


@media only screen
and (min-device-width: 850px)
and (max-device-width: 1050px)
{
    .btn-test {
        line-height: 34px;
        font-size: 8px;
    }

    .arrow-call-to-action {
        font-size: 8px;
    }

    .call-to-action-list p {
        font-size: 8px;
    }
}

所以我将屏幕设置为 900,媒体查询应该处于活动状态,但是我没有看到任何变化,我这样做正确吗?

谢谢。

更新HTML添加

 <li>
                <div class="t4 arrow-call-to-action">
                    somthing
                </div>

                <div class="t5">
                    <p>text
                        <br>more text<br>
                    </p>
                </div>

                <div class="t6">
                    <a href="#" class="btn-test"
                       id="some-tracking-id">Buy Now
                    </a>
                </div>
            </li>

如果您想通过调整浏览器大小进行测试,请使用 min-widthmax-width window。 Min-device-width 不会受到调整大小的影响,因为设备不会更改大小。

试试这个


@media (min-width: 850px) and (max-width: 1050px){}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <!-- Latest compiled and minified CSS -->

<!-- Optional theme -->

<!-- Latest compiled and minified JavaScript -->

<style>
.btn-test {
    border-radius: 2px;
    border: 1px solid #2e70a4;
    color: #fff;
    font-size: 12px;
    background: #2c83c9;
    position: relative;
    transition: all .2s ease;
    display: inline-block;
    text-decoration: none;
    margin: 18px 9px 0 0;
    padding: 5px 9px 0 9px;
    height: 37px;
    line-height: 16px;
    text-align: center;
}


@media only screen and (min-width:850px) and (max-width: 1050px)  {
     .btn-test {
        line-height: 34px;
        font-size: 8px;
         background: #fc9;
    }

    .arrow-call-to-action {
        font-size: 8px;
    }

    .call-to-action-list p {
        font-size: 8px;
    }
}
</style>

</head>
<body>
    <div class="container">
    <ul class="" role="tablist">
        <li>
                <div class="t4 arrow-call-to-action">
                    somthing
                </div>

                <div class="t5">
                    <p>text
                        <br>more text<br>
                    </p>
                </div>

                <div class="t6">
                    <a href="#" class="btn-test"
                       id="some-tracking-id">Buy Now
                    </a>
                </div>
            </li>
    </ul>
</div>
<script>
</script>
</body>
</html>