css - 空内容时body的background-position值为center无法居中。

查看:290
本文介绍了css - 空内容时body的background-position值为center无法居中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <style>
        body{        
            background-image: url(http://c.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=736f2a288a13632715b8ca37a4bf8cda/34fae6cd7b899e516d038ce042a7d933c9950db0.jpg);
            background-repeat: no-repeat;
            background-position:center;
        }

    </style>
</head>
<body>
    
</body>
</html>

效果很不好,图片有一半是在顶部被隐藏的

原图为

解决方案

 html, body {
    height: 100%;
    width: 100%;
 }

这篇关于css - 空内容时body的background-position值为center无法居中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆