【问题标题】:Responsive div element same as background image?响应式 div 元素与背景图像相同?
【发布时间】:2021-03-05 18:37:03
【问题描述】:

我有关于响应式设计的问题。我得到了需要设置为容器背景图像的背景图像。但我不知道该怎么做。 例如我试过这个 -

.container {
    width: 100%;
    background: url("img/bg3.svg") no-repeat;
    background-size: 100%;
    overflow: hidden;
    height: 100%;
}

到目前为止,我尝试过这个,如果我在移动高度大小上设置背景的 excat 大小会太多。有什么建议吗?

【问题讨论】:

    标签: html css frontend responsive


    【解决方案1】:

    试试这个

    .container {
            width: 100%;
            background: url("img/bg3.svg") no-repeat;
            background-size: cover;
            overflow: hidden;
            height: 100%;
        }
    

    【讨论】:

    • 感谢您的回复,但这也不起作用。
    • 你能用html分享你的代码吗
    • 我可以在哪里分享以免显得凌乱? html 中也没有任何内容 -
      .
    • 你也可以将这个添加到你的代码中 background-position: center center;但是,如果您也在为移动设备寻找完美的背景图片,我建议您使用具有较小背景图片的媒体查询
    猜你喜欢
    • 2013-06-27
    • 2015-12-04
    • 2020-04-10
    • 2014-03-26
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多