zoukankan      html  css  js  c++  java
  • full-background.js

    $(window).on('load', function () {
        $(window).trigger('resize');
    });
    
    $(function () {
      var $window = $(window),
      isLoaded = false;
    
      function resizeBg() {
        var winWidth = $window.width(),
          winHeight = $window.height(),
          viewportAspectRatio = winWidth / winHeight;
    
        $('.full-bg').each(function (index, item) {
          var $bg = $(item),
          bgWidth = $bg.width(),
          bgHeight = $bg.height(),
          aspectRatio = bgWidth / bgHeight;
    
            if (viewportAspectRatio < aspectRatio ) {
              $bg.removeClass('full-width')
                .addClass('full-height')
                .css({
                   top: 0,
                   left: -(winHeight * aspectRatio - winWidth) / 2
                 });
            } else {
              $bg.removeClass('full-height')
                .addClass('full-width')
                .css({
                  top: -(winWidth / aspectRatio - winHeight) / 2,
                  left: 0
                });
            }
        });
      }
      $window.on('resize', resizeBg);
    
      $('.full-bg').on('load', function () {
        $(window).trigger('resize');
      });
    });
    
    enquire.register('screen and (max- 760px)', {
      match: function () {
        $('.responsive-img').each(function () {
          var $img = $(this),
            src = $img.data('mobile-src');
          if (src) {
            $img.attr('src', src).show();
          } else {
            $img.hide();
          }
        });
      },
      unmatch: function () {
        $('.responsive-img').each(function () {
          var $img = $(this),
            src = $img.data('src');
          if (src) {
            $img.attr('src', src).show();
          } else {
            $img.hide();
          }
        });
      }
    });
    
    enquire.register('screen and (min- 761px)', {
      match: function () {
        $('.responsive-img').each(function () {
          var $img = $(this),
            src = $img.data('src');
          if (src) {
            $img.attr('src', src).show();
          } else {
            $img.hide();
          }
        });
      },
      unmatch: function () {
        $('.responsive-img').each(function () {
          var $img = $(this),
            src = $img.data('mobile-src');
          if (src) {
            $img.attr('src', src).show();
          } else {
            $img.hide();
          }
        });
      }
    });
  • 相关阅读:
    G. Yash And Trees 线段树 + dfs序 + bitset
    网络流最小割 H
    P2764 最小路径覆盖问题 网络流重温
    P4016 负载平衡问题 网络流重温
    D. Yet Another Subarray Problem 思维 难 dp更好理解
    J
    20190709 暑训 区间种类数 莫队的学习
    E
    线段树 离散化 E. Infinite Inversions E. Physical Education Lessons
    CbsPersist
  • 原文地址:https://www.cnblogs.com/Brittany-yan/p/5279242.html
Copyright © 2011-2022 走看看