【问题标题】:How to make background image of a DIV to be responsive?如何使 DIV 的背景图像响应?
【发布时间】:2014-01-31 10:39:23
【问题描述】:
.article_left_bg {
    background-image: url(images/article_bg_01.png);
    background-repeat: no-repeat;
    height: auto;
    min-height: 400px;
    margin-left: 20px;

}

.article_left2_bg {
    background-image: url(images/article_bg_03.png);
    background-repeat: no-repeat;
    height: auto;
    min-height: 320px;
    margin-left: 12px;
    margin-top: -30px;
}

.article_left3_bg {
    background-image: url(images/article_bg_05.png);
    background-repeat: no-repeat;
    height: auto;
    min-height: 400px;
    margin-left: 8px;
    margin-top: -15px;
}

.article_right_bg {
    background-image: url(images/article_bg_02.png);
    background-repeat: no-repeat;
    height: auto;
    min-height: 400px;

}

.article_right2_bg {
    background-image: url(images/article_bg_04.png);
    background-repeat: no-repeat;
    height: auto;
    min-height: 320px;
    margin-top: -30px;
}

.article_right3_bg {
    background-image: url(images/article_bg_06.png);
    background-repeat: no-repeat;
    height: auto;
    min-height: 320px;
    margin-top: -15px;
}

.article_title, .article_title1, .article_title2 {
    width: 350px;
    padding-bottom:15px;
    margin-bottom:15px;
    }

.article_title h2 {
    margin:20px 0 5px 0;
    color:#000;
    font-size:25px; 
    font-weight:normal;
    padding: 50px 0 0 58px;
    }

.article_title1 h2 {
    margin:20px 0 5px 0;
    color:#000;
    font-size:25px; 
    font-weight:normal;
    padding: 90px 0 0 58px;
    }

.article_title2 h2 {
    margin:20px 0 5px 0;
    color:#000;
    font-size:25px; 
    font-weight:normal;
    padding: 60px 0 0 68px;
    }


.article_title h2 a, .article_title1 h2 a, .article_title2 h2 a{
    color:#000}


.article_title .subtitle, .article_title1 .subtitle {
    display:block;
    font-size:15px;
    font-weight:300;
    color:#000;
    padding: 0 0 0 58px;
    }

.article_title2 .subtitle {
    display:block;
    font-size:15px;
    font-weight:300;
    color:#000;
    padding: 0 0 0 68px;

}

.article_descr {
    width: 290px;
    color:#000;
    font-size:12px;
    line-height:1.2em;
    font-family:Arial, Helvetica, sans-serif;
    padding: 0 0 0 58px;
    }

.article_item .link_more,
.article_item .link_more:hover {
    display:inline-block;
    line-height:25px;
    background:url(images/arrow_right.png) 0 0 no-repeat;
    padding-left:45px;
    font-weight:400;
    font-size:18px;
    color:#000;}

我想要 3 行 2 列,每个框都有不同的图像作为背景。但是,当涉及到移动设备时,它会变得很糟糕。图像仅显示一半,并且文本从图像中显示为已损坏。

我会请求任何人帮助我将 div 背景图片制作为响应式图片。

谢谢

TeekeyBee

【问题讨论】:

    标签: image text background


    【解决方案1】:

    background-size: cover; 有帮助吗?

    background-size CSS 属性指定背景图像的大小。图像的大小可以完全限制或仅部分限制,以保持其固有比例。

    Here有关它的更多信息。

    【讨论】:

    • 你能在演示中提供一些标记吗(jsFiddle/Codepen/etc)?
    • jsfiddle.net/Teekeybee/C8aLX - 我对这个 jsfiddle 很陌生,如果有任何错误请见谅
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 2022-12-10
    • 1970-01-01
    • 2020-04-10
    相关资源
    最近更新 更多