zoukankan      html  css  js  c++  java
  • 背景图以拉伸方式(不重复)填充背景

    今天要解决一个用背景图以拉伸方式(不重复)填充背景的问题。

    看了《用CSS把背景图片拉伸》和《css 如何让背景图片拉伸填充避免重复显示》后用background-repeat配合background-size解决了底图不重复的问题。但另一个问题来了,图片是按宽度作为比例进行缩放的,如果这张图是横向,在手机竖向时,下面一截就空了,如下图:

    再次看《用CSS把背景图片拉伸》时发现示例中有 background-attachment: fixed; 属性加上一试,Ok了。 如下图

    最终代码如下:

    .background-pic
    {
    background-image: url(图片地址);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    }

  • 相关阅读:
    三个习题
    20 python--celery
    19 python --队列
    18 python --多线程
    17 python --多进程
    16 python --memcached
    15 python --redis
    14 python --mysql
    13 python --正则
    12 python --json
  • 原文地址:https://www.cnblogs.com/borter/p/9480566.html
Copyright © 2011-2022 走看看