繁体   English   中英

如何使背景图像充分显示并覆盖整个尺寸

[英]How to make background image to be displayed fully and to cover the full size

我有一个标题div,我想完全覆盖一个背景图片。 我希望图像能完整显示,所以没有裁剪。 但是,它似乎正在拉伸图像并对其进行裁剪。

CSS:

..header{

        border-top-left-radius:5px;
        border-top-right-radius: 5px;
        max-width: 600px;
        width:100%;
        height: auto;
        min-height: 200px;
        background: url("img/bg-abstract.jpg") no-repeat fixed;
        background-position: left top;
        background-size: 100%;
        position: relative;
        background-attachment: fixed;
        background-repeat: no-repeat;

    }

您需要的是

background-size:cover

background-size: cover也请尝试使用%而不是px

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM