媒体查询无响应

时间:2016-07-11 10:34:06

标签: html css responsive-design media-queries

好的,所以我有一段时间没有使用媒体查询,但我相信我已经正确完成了。 我不是在使用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>

3 个答案:

答案 0 :(得分:1)

如果要通过调整浏览器窗口大小进行测试,请使用min-widthmax-width。 <{1}}不会受到调整大小的影响,因为设备不会改变大小。

答案 1 :(得分:1)

试试这个

DECLARE @M INT = 1
DECLARE @SQL VARCHAR(MAX) = ''
DECLARE @Cnt INT = 1
DECLARE @Month VARCHAR(25)

WHILE @Cnt <= 12
    BEGIN
        SET @Month = ( DATENAME(m, '2016-' + CONVERT(VARCHAR(2), @M) + '-01') )

        SET @SQL = @SQL + 'select ' + CONVERT(VARCHAR(25), @M) + ' as M, ''' + @Month + ''' as Month'
        IF @Cnt <> 12
            SET @SQL = @SQL + ' Union All '  



        SET @Cnt = @Cnt + 1
        SET @M = @M + 1
    END

EXEC  (@SQL)

答案 2 :(得分:0)

<!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>