zoukankan      html  css  js  c++  java
  • 如何让背景图片固定在中间,滚动内容图片不动?

    实例

    如何设置固定的背景图像:

    body 
      { 
      background-image: url(bgimage.gif); 
      background-attachment: fixed;
      }

    定义和用法

    background-attachment 属性设置背景图像是否固定或者随着页面的其余部分滚动。

    默认值: scroll
    继承性: no
    版本: CSS1
    JavaScript 语法: object.style.backgroundAttachment="fixed"

    可能的值

    描述
    scroll 默认值。背景图像会随着页面其余部分的滚动而移动。
    fixed 当页面的其余部分滚动时,背景图像不会移动。
    inherit 规定应该从父元素继承 background-attachment 属性的设置。

    以上的写法 如果在手机里面会出现兼容问题,怎么办??

    看下面解决方法:

    body:before{
    content: ' ';
    position: fixed;
    z-index: -1;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: url(../images/bj-1.jpg) top center no-repeat;
    background-size: cover;
    }

  • 相关阅读:
    css--兼容写法整理
    vuerouter-7._路由高亮
    vuerouter-6_路由杂项
    vuerouter-5.参数传递
    vuerouter-4.编程式导航
    vuerouter-3.路由嵌套
    正则表达式
    STL容器迭代器失效分析
    coredump
    获取结构体成员偏移量
  • 原文地址:https://www.cnblogs.com/hailun/p/5520492.html
Copyright © 2011-2022 走看看