图片背景居中且顶部对齐的页面设计

背景图居中

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片背景对比页面</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            min-height: 100vh;
            overflow-x: hidden;
            position: relative;
        }
        
        #background-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            min-height: 100%;
            z-index: -999;
            /* 背景图片设置 */
            background-image: url('./1.jpg');
            background-position: center top; /* 图片居中且顶部对齐 */
            background-size: auto; /* 保持图片原有宽度 */
            background-repeat: no-repeat;
            background-color: #f0f0f0; /* 备用背景色 */
        }
        
        
        @media (max-width: 768px) {
            .content {
                padding: 25px;
            }
            
            h1 {
                font-size: 2rem;
            }
            
            .features {
                flex-direction: column;
            }
            
            .controls {
                width: 200px;
                right: 10px;
            }
        }
    </style>
</head>
<body>
    <!-- 背景图片容器 -->
    <div id="background-container"></div>
   
</body>
</html>


1、本站目前拥有近 1000+ 精品收费资源,现在加入VIP会员即可全部下载。
2、本资源部分来源其他付费资源平台或互联网收集,如有侵权请联系及时处理。
川芎模板网 » 图片背景居中且顶部对齐的页面设计

发表评论

加载中~

加入本站VIP会员订阅计划,海量资源免费查看

目前为止共有 3654 位优秀的VIP会员加入! 立刻加入VIP会员