CSS :
img {
opacity: 0.5;
-webkit-transition: opacity 0.5s linear;
}
img:hover {
opacity: 1;
-webkit-transition: opacity 0.5s linear;
}
jQuery를 :
$('img').css('opacity',0.5);
$('img').hover(
function(){
$(this).stop().animate({opacity: 1}, 500);
},
function(){
$(this).stop().animate({opacity: 0.5}, 500);
});
JS Fiddle demo of both of the above techniques.
하지 경기 선택기을 이러한 요소를 대상으로하려면, 당신은 사용할 수 있습니다
$('#jQueryOnlyV2 img:not(".noFading")').css('opacity',0.5);
$('#jQueryOnlyV2 img:not(".noFading")').hover(
function(){
$(this).stop().animate({'opacity':1},500);
},
function(){
$(this).stop().animate({'opacity':0.5},500);
});
을 선택이 요소 내에 포함 된 CSS를 class="noFading"
이없는 모든 이미지를 일치 식에서 id="jQueryOnlyV2"
.
CSS3 선택기 구문을 사용합니다 (단, jQuery not()
도 비슷하게 사용할 수 있음).
Revised jQuery demo. 당신이 마우스 오버에 완전 불투명 바로 '팝업'에 아이템을 원하는 경우에
@VincePettit는'0'에 위의 첫 번째'500'을 변경합니다. – Phrogz
감사합니다. 특정 이미지에 어떻게 적용합니까? 내비게이션 이미지 중 일부는 내가 원하지 않는 색을 깎아 내기 때문에 사라집니다. –
@Vince Pettit : jQuery는 대상 요소에 CSS 스타일 선택기를 허용합니다. 마크 업을 게시하면 포인터를 제공 할 수 있습니까? 지침을 제공해야하는 [게시 된 JS Fiddle 데모] (http://jsfiddle.net/davidThomas/eFSG8/)를 보면. –