1、前端背景图自适应

如何实现前端背景图片自适应浏览器窗口大小,只需要添加如下CSS样式既可,

            background-image: url("../image/bcg.jpg");
            background-repeat: no-repeat;
            background-size: cover;
            -webkit-background-size: cover;
            -o-background-size: cover;
            background-position: center 0;

测试代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
    <style>
        body{
            /*background: url("../image/bcg.jpg");*/
            background-image: url("../image/bcg.jpg");
            background-repeat: no-repeat;
            background-size: cover;
            -webkit-background-size: cover;
            -o-background-size: cover;
            background-position: center 0;
        }
    </style>
</head>
<body>
<!--顶部公司图标-->
<div></div>
<!--中间注册信息-->
</body>
</html>

在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐