背景样式

背景样式
设置全屏背景
背景颜色:<body bgcolor="red"></body>
背景图片:<body background="lq.jpg"></body>
如果图片大小不合适,则画面显示存在问题
背景样式:
width: 600px;
height: 768px;
background-image: url("lq.jpg");
background-repeat: no-repeat;/*过小时不重复*/
background-position: 25px 50px/*距离左边界25,上边界50*/;
background-attachment: scroll; 设置依附方式
background-repeat: xx;
repeat:横纵向都重复
repeat-x:横向重复
repeat-y:纵向重复
background-attachment:xx;
fixed:背景图不随滚动条变化而变化
scroll:随滚动条一起变化而变化
也可通过:
background:lq.jpg no-repeat scroll 25px 50px
背景全屏设置,不重复
#d2{
width: 700px;
height: 800px;
background-image: url("lq.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
background-attachment: scroll;

}
百分比设置
可以让其适应不同的设备
首先必须要保证父元素已经设置了尺寸
<style>
html,body{
width: 100%;
height: 100%;
}
#p1{
width: 50%;
height: 50%;
background: gold;
}

</style>

posted @ 2020-08-24 16:03  龙陌  阅读(114)  评论(0编辑  收藏  举报