CSS-背景

最简介的写法

body
{ 
  background: #00FF00 url(bgimage.gif) no-repeat fixed top;
}

inherit 属性将继承父类该属性

background对应的属性分别有:

  • background-attachment :
作用
scroll随页面滚动而滚动
fixed不随页面滚动
  • background-color
body {background-color: yellow}
h1 {background-color: #00ff00}
h2 {background-color: transparent}
p {background-color: rgb(250,0,255)}
  • background-image
body
{ 
  background-image: url(bgimage.gif);
}
  • background-position
top left
top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
x% y% 水平位置和垂直位置,左上角是0% 0%默认是50%
xpos ypos 水平位置和垂直位置,左上角是0 0 ,默认是50%
  • background-repeat
作用
repeat默认。背景图像将在垂直方向和水平方向重复。
repeat-x背景图像将在水平方向重复。
repeat-y背景图像将在垂直方向重复。
no-repeat背景图像将仅显示一次。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值