0
jQuery를 사용하여 div 밖으로 슬라이드를 만들려고합니다. 사진 위에 마우스를 올려 놓으면 div가 슬라이드 아웃하여 사진을 부분적으로 덮습니다 (정보가 포함 된 상태).jQuery에 대한 슬라이드 인/아웃 토글
나는 자바 스크립트를 조합했지만 작동하지 않는 것 같습니다.
정보]는 display:none
하지만
jQuery를 사용하여 div 밖으로 슬라이드를 만들려고합니다. 사진 위에 마우스를 올려 놓으면 div가 슬라이드 아웃하여 사진을 부분적으로 덮습니다 (정보가 포함 된 상태).jQuery에 대한 슬라이드 인/아웃 토글
나는 자바 스크립트를 조합했지만 작동하지 않는 것 같습니다.
정보]는 display:none
하지만
가 여기에 하나의 접근 방식 (오른쪽에서 밖으로 밀어한다) 이미지를 가리킬 때 표시해야합니다 :
$("#snoodLink").hover(
function() {
$('#snoodInfo').animate({
left: 0,
right: 0
}, 500);
}, function() {
$('#snoodInfo').animate({
left: '-100%',
right: '100%'
}, 500);
});
다음 CSS를 사용하여 :
.product {
/* ensures the positioned text element isn't
visible before sliding in/after sliding out */
overflow: hidden;
}
#snoodInfo {
position: absolute;
top: 0;
left: -100%;
right: 100%;
width: 100%;
background-color: rgba(255,255,255, 0.5);
}
덧붙여, 이것은 (이전의 IE에 대한 우아한 저하) CSS와 함께 할 수있다 :
.product {
position: relative;
overflow: hidden;
/* following just center the image/element
absolutely not necessary */
width: 50%;
margin: 1em auto;
}
.product img {
width: 100%;
}
/* this is the #snoodInfo element, given a class
insead of id, to make it more generic */
.info {
position: absolute;
top: 0;
left: -100%;
right: 100%;
width: 100%;
/* to enforce the fade-in/fade-out */
color: transparent;
background-color: transparent;
/* trying to cover as many browsers
as possible, omitting early/old IE
but filters could (probably) be used */
-webkit-transition: all 1.5s linear;
-moz-transition: all 1.5s linear;
-ms-transition: all 1.5s linear;
-o-transition: all 1.5s linear;
transition: all 1.5s linear;
}
.product:hover .info {
left: 0%;
right: 0%;
color: #000;
background-color: #fff;
background-color: rgba(215,50,50,0.8);
-webkit-transition: all 1.5s linear;
-moz-transition: all 1.5s linear;
-ms-transition: all 1.5s linear;
-o-transition: all 1.5s linear;
transition: all 1.5s linear;
}
고마워요! 나는이 사이트를 내 사이트에서 구현하려고 시도했지만 JS Fiddle과 동일한 코드를 사용하고 있지만 작동하지 않는 것으로 보입니다. 무엇이 충돌하고 있는지 확실하지 않습니다. www.rubytuesdaycreative.co.uk/testsite/shop.html – Francesca
페이지의 첫 번째 이미지에 추가했습니다. 오류 콘솔 보고서 : * 잡히지 않은 구문 오류 : 예기치 않은 토큰 ILLEGAL *. 이것은 아마도 JS Fiddle이 포맷 용도로 사용하는 보이지 않는/제로 너비 문자에 이르기까지합니다. 가장 쉬운 방법은 붙여 넣은 코드에서 * all * 공백을 삭제 한 다음 다시 시도하는 것입니다 (때로는 공백 앞/뒤에있는 각 보이는 문자를 삭제하고 다시 입력해야하는 경우도 있습니다). 사실, 짧은 스 니펫의 경우에는 복사/붙여 넣기없이 손으로 입력하면됩니다. 바라기를 그 때 일해야한다! –
코드를 다시 작성했지만 여전히 작동하지 않는 것 같습니다. 링크를 업데이트했습니다. 흥미로운 quirk. – Francesca