在html代码中怎么让背景图片居中

如题所述

用background-position属性来实现。

参考代码:

<html>
<head>
<style type="text/css">
body
{
background-image:url(/i/eg_bg_desert.jpg);'背景图
background-position: center center ; '居中
background-repeat:no-repeat;'图片不重复

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

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-11-08
纯粹的背景图居中,不考虑是否填满区域的话,可以用background-position:center center;
考虑到要填满整个区域,可以使用background-size:cover本回答被网友采纳
第2个回答  2016-11-08
background-size:cover;

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网