jquery ui resizable bug解決方案_jquery

來源:互聯網
上載者:User
但開啟 helper: 'ui-resizable-helper' 或animate: true, 時候,會發現官方的例子的寬度自動增加了10PX 仔細翻原始碼一看,發現有以下問題:(如圖)


竟然用padding 難怪會自動添加寬度
這個問題在ie firefox下都存在.
其中這個問題比較難發現,但你可以用以下代碼測試出來:
複製代碼 代碼如下:

<style type="text/css">
#resizable { width: 350px; height: 150px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; }
.ui-resizable-helper { border: 1px dotted #ddd; }
</style>
<script type="text/javascript">
$(function() {
$("#resizable").resizable({
maxWidth: 350,#讓最大寬度和最小寬度一致
minHeight: 150,
minWidth: 350,
helper: 'ui-resizable-helper'
});
});
</script>
</head>
<body>
<div id="resizable" class="ui-widget-content">
test
</div>
</body>


只要把上面的

 #resizable { width: 350px; height: 150px; padding: 0.5em; }
 #resizable h3 { text
-align: center; margin: 0; }

改為:

 #resizable { width: 350px; height: 150px; }
 #resizable h3 { text
-align: center; margin: 5px; } 

即可.

其實細心一點會發現還有問題:

 

其實就是ui-widget-content的邊框的大小為1px造成的,所以,我們改把#resizable的寬度在縮小2px

修改代碼:

 #resizable { width: 350px; height: 150px; }

為:

#resizable { width: 348px; height: 150px; } 

在測試,正常了.

發現JQUI的小問題還真不少....

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.