背景定位和背景固定

background-position
body{
      background-image:url('bgimage.gif');
      background-repeat:no-repeat;
      background-attachment:fixed;
      background-position:center;
}

top left
top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
如果您仅规定了一个关键词,那么第二个值将是"center"。

  • 默认值:0% 0%
  • 我们常用负值来定位
background-attachment
    body{
      background-image:url('bgimage.gif');
      background-repeat:no-repeat;
      background-attachment:fixed;
      background-position:center;
}

scroll  默认值。背景图像会随着页面其余部分的滚动而移动。
fixed  当页面的其余部分滚动时,背景图像不会移动。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、CSS入门 1、css选择器 选择器的作用是“用于确定(选定)要进行样式设定的标签(元素)”。 有若干种形式的...
    宠辱不惊丶岁月静好阅读 1,650评论 0 6
  • 学会使用CSS选择器熟记CSS样式和外观属性熟练掌握CSS各种选择器熟练掌握CSS各种选择器熟练掌握CSS三种显示...
    七彩小鹿阅读 6,356评论 2 66
  • 1. 定义和用法 background是一个简写属性,可以在一个声明中设置所有的背景属性,可设置的属性如下: 这些...
    lightNate阅读 4,455评论 2 9
  • day01­_起源和结构 结构:Xhtml xml 表现:CSS 行为:DOM ECMAScript 以上都属于W...
    Sakura_明妃阅读 1,248评论 0 1
  • 学习CSS的最佳网站没有之一 http://www.w3school.com.cn/tags/index.asp ...
    Amyyy_阅读 1,102评论 0 1