您的位置:首页 > Web前端 > CSS

从0开始html前端页面开发_CSS实现设置背景图自适应屏幕大小

2018-03-06 14:21 921 查看
只需要在css样式里对BODY元素添加css样式即可
html代码如下<STYLE TYPE="text/css">
BODY {background-image: URL(../../ui/loading/loading_page.png);
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
}
</STYLE>
元素介绍:
要显示的背景图URL地址!

background-image:背景图的起始位置
background-position: bottom; 可取以下参考属性

属性值说明
top left左上
top center靠上居中
top right右上
left center靠左居中
center center正中
right center靠右居中
bottom left左下
bottom center靠下居中
bottom right右下
设置背景图的平铺模式
background-repeat;可取以下参考属性
no-repeat//不允许平铺
需要设置background-attachment属性才能确保在Firefox 和 Opera中正常显示
background-attachment可取以下参考属性:fixed

css代码BODY {background-image: URL(../../ui/loading/loading_page.png);
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: