javascript如何制作div id =" odometerDiv"在窗口调整大小时更改其宽度?

时间:2017-08-26 08:45:48

标签: javascript jquery resize media-queries window-resize

如何制作div id =" odometerDiv"在窗口调整大小时更改其宽度,以便:

  1. 宽度超过600px时,有更大的宽度断点和

  2. 600px以下有更小的宽度断点?

  3. 以下是我的观察:

    https://jsfiddle.net/xawyvwm4/2/

    jsFiddle中的第4行:

    if($(document).width() > 600) {
      this.digits = 6;
      this.tenths = 0;
      this.digitHeight = 27;
      this.digitPadding = 5;
      this.digitWidth = 20;
      this.bustedness = 2;
      this.fontStyle = "font-family: Courier New, Courier, monospace; font-weight: 900;";
      this.value = -1;
        } else {
      this.digits = 6;
      this.tenths = 0;
      this.digitHeight = 17;
      this.digitPadding = 5;
      this.digitWidth = 10;
      this.bustedness = 2;
      this.fontStyle = "font-family: Courier New, Courier, monospace; font-weight: 900;";
      this.value = -1;  
      }
    

    jsFiddle中的第139行:

    $(window).on("resize", function() {
      odometer();
    });
    

0 个答案:

没有答案