[JavaScript] jquery让所有浏览器都支持min/max-width样式 →→→→→进入此内容的聊天室

来自 , 2019-07-29, 写在 JavaScript, 查看 102 次.
URL http://www.code666.cn/view/6b3c49bd
  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

回复 "jquery让所有浏览器都支持min/max-width样式"

这儿你可以回复上面这条便签

captcha