阅读背景:

(CSS)无法为移动设备调整背景图像大小

来源:互联网 
  /* Responsive Full Background Image Using CSS
  * Tutorial URL: https://sixrevisions.com/css/responsive-background-image/
  */

  body {
      /* Location of the image */
      background-image: url(images/background-photo.jpg);
      /* Image is centered vertically and horizontally at all times */
      background-position: center center;
      /* Image doesn't repeat */
      background-repeat: no-repeat;
      /* Makes the image fixed in the viewport so that it doesn't move when 
     the content height is greater than the image height */
      background-attachment: fixed;
      /* This is what makes the background image rescale based on its container's size */
      background-size: cover;
      /* Pick a solid background color that will be displayed while the background image is loading */
      background-color: #464646;
      /* SHORTHAND CSS NOTATION
   * background: url(background-photo.jpg) center center cover no-repeat fixed;
   */
      min-width: 100%;
      max-width: 100%;
      min-height: 100%;
      max-height: 100%;
  }
  /* For mobile devices */

  @media only all and (max-width: 768px) {
      .logo {
          /* The file size of this background image is 93% smaller
     * to improve page load speed on mobile internet connections */
          background-image: url(images/background-photo-mobile-devices.jpg);
          height: 300px;
          width: 100%;
          background-size: contain;
          background-repeat: no-repeat;
          background-position: center;
      }
  }
  /* Responsive Full Background Image Using CSS



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: