全屏响应式背景图片

时间:2021-05-07 13:33:45

标签: css image background frontend

背景图片在大屏幕上不显示为全图,但适合小屏幕。

<!DOCTYPE html>
<html dir="ltr">
<head>
    <meta charset="utf-8" dir="ltr" />
    <title></title>

    <style>

     
        body, html {
            height: 100%;
            margin: 0;
        }

        .bgImage {
            /* The image used */
            background: url(../../../Content/imgs/common/myimage.png) no-repeat center ;
            height: 100%;
            background-size: cover;
        }
       
    </style>
</head>
<body>
    <div class="bgImage">
        
    </div>
</body>
</html>

是否有特定尺寸的图像可以在所有屏幕上都具有响应性?

1 个答案:

答案 0 :(得分:0)

尝试添加 background-position:center background-attachment:fixed 到您的 bgimage 类

相关问题