1

I've created a jsFiddle here to illustrate my problem in code (Double click the pink element and try to drag on outside the blue box, double click again and compare the results).

Problem:

When I make a CSS rotate on a draggable element with a constraint, the constraint doesn't work as expected. The draggable element can be dragged partially outside the container. My guess is that it has something to do with how the CSS rotate works, but I'm not sure.

Is there some way to solve this problem?

4

1 に答える 1

2

cssでrotateを適用しても、タグの幅と高さは変わらないようです。そのため、ブラウザの場合、タグのサイズ(および制限)は変更されないため、divを外部に移動できます。divを調べるだけでそれを確認できます。

幅と高さを知っている場合は手動で設定するか、cssクラスを切り替えるたびに動的に計算することができます。

あなたの質問に似たこの投稿を参照してください

編集

私はあなたがやりたいことをするための解決策を見つけました。秘訣は、コンテナdivをドラッグ可能なアイテムとして使用し、子divの回転を管理することです。次に、子の左上のプロパティを調整する必要があります。私はより良い式を探していませんでした、そして単に固定値を適用しました。しかし、それが機能するかどうかを確認するだけでした。

これがお役に立てば幸いです。

http://jsfiddle.net/Sp6qa/2/

于 2012-04-04T15:04:01.537 に答える