Get the browser's height, width, and monitor the browser's wide mouth size changes

Question 1: Get the width and height of the browser? Get width and height of text?

Solution: browser with border: $(window).outerWidth();

               Browser without borders: $(window).width();

               Browser with border: $(window).outerHeight();

               Browser without border: $(window).height();

               Text with border: $(document).outerwidth();

               Text without borders: $(document).width();

Question 2: Monitor browser window changes?

Solution:

  $(window).resize(function () {
           // things to do...
  })

Question 3: If the text content is too long, a scroll bar will appear. When viewing an element, the element can be scrolled to the visual screen.

Solution: Calculate the distance from the top of an element + the scrolling distance of the parent container's scroll bar.

  //scroll effect
                            var scrollTop = $('.center_img').scrollTop();//The scrolling distance of the scroll bar in the container
                            var dotop = $('.biaoDiv #' + id).offset().top;//The distance of an element from the top of the document
                            hei = $('.center_img').offset().top;//The distance between the parent container of the element and the top of the document
                            $('.center_img').animate({
                                scrollTop: scrollTop + dotop - hei
                            }, 500);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325809567&siteId=291194637