背景图片相关设置

body

background-image:url('smiley.gif');//图片地址
background-repeat:no-repeat;//是否重复
background-attachment:fixed;//网页滚动时,背景图片是否跟着滚动
background-position:center; 
}

background-attachment

scroll:默认值。背景图像会随着页面其余部分的滚动而移动。

fixed:当页面的其余部分滚动时,背景图像不会移动。

inherit:规定应该从父元素继承 background-attachment 属性的设置。

演示地址:http://www.w3school.com.cn/tiy/t.asp?f=csse_background-attachment

background-position:

描述
left top
left center
left bottom
right top
right center
right bottom
center top
center center
center bottom
如果仅指定一个关键字,其他值将会是"center"
x% y% 第一个值是水平位置,第二个值是垂直。左上角是0%0%。右下角是100%100%。如果仅指定了一个值,其他值将是50%。 。默认值为:0%0%
xpos ypos 第一个值是水平位置,第二个值是垂直。左上角是0。单位可以是像素(0px0px)或任何其他 CSS单位。如果仅指定了一个值,其他值将是50%。你可以混合使用%和positions
inherit 指定background-position属性设置应该从父元素继承

猜你喜欢

转载自www.cnblogs.com/cowboybusy/p/9052058.html
今日推荐