div를 이동하여 (box2) 화면 오른쪽으로 이동하고 사용자가 다른 div (box1)를 가리키면 사라지는 방법을 알고 싶습니다. Jquery를 사용해야한다는 것을 알고 있습니다. 현재로서는 box2를 토글 기능을 사용하여 사라지게 만드는 방법을 알고 있지만 애니메이션 기능을 사용하여 오른쪽으로 이동 한 다음 사라지는 방법은 확실하지 않습니다. 어떤 도움이라도 대단히 감사하겠습니다.jQuery를 사용하여 div 이동하기
-1
A
답변
0
$ .animate() 사용법을 묻는 중입니까? 기본적으로
http://api.jquery.com/animate/
... 당신의 선택에$(document).ready()
{
$(selector).animate(
{
"backgroundColor" : "red"
}, 500, "swing");
}
플러그, 해당 작업을 수행하는 방법을 알고 있어야합니다.
Animate에는 두 가지 주요한 논점이 있지만 세 번째는 "완화"입니다.
첫 번째는 CSS 변경 사항이 포함 된 개체 리터럴입니다.
두 번째는 애니메이션이 완료되는 데 걸리는 시간 (밀리 초)입니다.
세 번째는 부드럽게하기 때문에 커브에서 애니메이션을 적용 할 수 있습니다. 기본값은 "선형"이며 딱딱하게 보입니다.
귀하의 질문은 실제로 존재하지 않는 것 같습니다. 방금 일반 정보를 요구하는 경우 먼저 검색 엔진에서 찾으십시오. 화면 전체 엘리먼트를 슬라이딩하고 그것을 페이딩
2
편도
// get the widths of the window (or the parent of the element to move):
var winWidth = $(window).width(),
// get the width of the element itself:
demoWidth = $('#demo').width(),
// find out how far to move the element:
delta = winWidth - demoWidth,
// the time-frame over which to animate:
duration = 1500;
// bind the animate method:
$('#demo').animate({
// move the element the distance held by the 'delta' variable:
'left': delta
// animate for the duration defined by 'duration':
}, duration,
// callback function, to occur once first stage of the animation has completed:
function() {
// binding the fadeOut() method:
$(this).fadeOut(duration);
});
<div id="demo"></div>
그리고 CSS : 다음 #box1
요소가 공중 선회 오버되면
#demo {
width: 5em;
height: 5em;
background-color: #f00;
/* to move an element, using the 'left' property,
the 'position' must be set to a value other than 'static' (the default):
*/
position: relative;
}
는, 동일한 작업을 수행하려면 :
var winWidth = $(window).width(),
demoWidth = $('#box2').width(),
delta = winWidth - demoWidth,
duration = 1500;
$('#box1').mouseenter(function() {
$('#box2').animate({
'left': delta
}, duration,
function() {
$(this).fadeOut(duration);
});
});
는 위의 데모는 (단순) HTML을 사용하여
JS Fiddle demo. 다음 HTML을 사용하여 위의
:
<div id="box1"></div>
<div id="box2"></div>
참고 :
0
여러 가지 방법이 있지만 호버에서 hover() 및 animate()를 사용할 수 있습니다.
<div class='slide-right'>howdy</div>
<div class='slide-right'>doody</div>
슬라이딩 오른쪽을 수행하는 데 사용하는 속성은 전적으로 귀하에게 달려 있습니다. 여기서는 예로서 왼쪽 여백을 움직입니다. 이것은 레이아웃에 영향을 미치므로 대신 left
과 절대 위치 지정을 사용해보십시오. 뷰 안팎으로 슬라이드 할 때 불투명도를 선택적으로 애니메이트 할 수 있습니다.
$('.slide-right').hover(function()
{
$(this).siblings('.slide-right').animate({ 'margin-left': '+=50' });
},
function()
{
$(this).siblings('.slide-right').animate({ 'margin-left': '-=50' });
});
관련 문제
- 1. jQuery 스크롤 렛을 사용하여 div 이동하기
- 2. jQuery를 사용하여 목록 상자간에 항목 이동하기
- 3. JQuery를 사용하여 DIV 배치하기
- 4. jquery를 사용하여 다시로드 div
- 5. jquery를 사용하여 div 제거
- 6. jquery를 사용하여 div 숨기기
- 7. Jquery를 사용하여 div 변경
- 8. JQuery를 사용하여 div 전환
- 9. jquery를 사용하여 div 마스크하기
- 10. jQuery를 사용하여 스크롤 div
- 11. jquery를 사용하여 한 목록 상자에서 다른 목록 상자로 항목 이동하기
- 12. Jquery를 사용하여 div 사용 안 함
- 13. 내 DIV 여기에서 jQuery를 사용하여 jQuery를
- 14. jquery를 사용하여 부모 div 삭제
- 15. jquery를 사용하여 특정 div 인쇄하기
- 16. jQuery를 사용하여 html div 추가
- 17. jQuery를 사용하여 이전 div 선택
- 18. jquery를 사용하여 div 크기 조작
- 19. JQuery를 사용하여 div 가시성 전환
- 20. jQuery를 사용하여 배경색으로 div 찾기
- 21. jQuery를 사용하여 div 간 이동
- 22. jquery를 사용하여 div 내에서 페이지로드하기
- 23. jQuery를 사용하여 div 태그 표시
- 24. Jquery를 사용하여 div 태그 업데이트
- 25. 전환 지연 옵션 (css)과 JS를 사용하여 div 이동하기
- 26. jquery 토글을 사용하여 왼쪽에서 오른쪽으로 여러 div 이동하기
- 27. 미디어 쿼리로 인라인에서 스택으로 div 이동하기
- 28. 마우스 버튼을 클릭하여 계속해서 DIV 이동하기
- 29. moveAsLastChildOf를 사용하여 노드 이동하기
- 30. UIButton을 사용하여 UIImageView 이동하기
아무 것도 jQuery를 사용할 필요가 없습니다. –
당신은 이미 가지고있는 것에서 jsfiddle을 만들까요? – vector