响应背景CSS位置

时间:2013-12-19 12:23:04

标签: html css css3 background-image

我的手机背景有问题。

我使用媒体查询而无法确定该背景图片的位置。

您可以在此处查看a background image

这是我的媒体查询代码:

@media only screen (max-device-width : 360px) {

    .sidebar {
        display: none;
    }

    li#menu-item-631 a {
        width: 100px;
    }

    #navmenu {
        margin-top: 20px;
        margin-left: 0;
        margin-right: 0;
    }

    .content {
        width: auto;
        height: auto;
        margin-left: 0;
        margin-top: -130px;
    }

    .contentsing {
        width: 500px;
        height: auto;
        margin-left: 20%;
        margin-right: 5%;
        margin-top: -150px;
    }
}

这是我的背景代码

body {
    background: url() no-repeat top center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    font-family: AntonioLight;
    font-size: 1em;
    padding: 0;
    margin: 0;
}

1 个答案:

答案 0 :(得分:1)

如果您希望背景图像适应不同的屏幕尺寸(例如,优先考虑图像的中心),您可能会寻找以下内容:http://johnpatrickgiven.com/jquery/background-resize/