JQuery enables all browsers to support the min/max-width style

From , 4 Years ago, written in JavaScript, viewed 54 times.
URL https://pastebin.vip/view/8b2a9c17
  1. <script type="text/javascript">
  2. //anonymous function to check all elements with class .fixMinMaxwidth
  3. var fixMinMaxwidth=function()
  4. {
  5.        //only apply this fix to browsers without native support
  6.        if (typeof document.body.style.maxHeight !== "undefined" &&
  7.                typeof document.body.style.minHeight !== "undefined") return false;
  8.  
  9.        //loop through all elements
  10.        $('.fixMinMaxwidth').each(function()
  11.        {
  12.                //get max and minwidth via jquery
  13.                var maxWidth = parseInt($(this).css("max-width"));
  14.                var minWidth = parseInt($(this).css("min-width"));
  15.  
  16.                //if min-/maxwidth is set, apply the script
  17.                if (maxWidth>0 && $(this).width()>maxWidth) {
  18.                        $(this).width(maxWidth);
  19.                } else if (minWidth>0 && $(this).width()<minWidth) {
  20.                        $(this).width(minWidth);
  21.                }
  22.        });
  23. }
  24.  
  25. //initialize on domready
  26. $(document).ready(function()
  27. {
  28.        fixMinMaxwidth();
  29. });
  30.  
  31. //check after every resize
  32. $(window).bind("resize", function()
  33. {
  34.        fixMinMaxwidth();
  35. });
  36. </script>
  37. //javascript/4261

Reply to "JQuery enables all browsers to support the min/max-width style"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website