jQuery jQuery BlackAndWhite 플러그인으로 이미지 흑백 효과 적용하기
페이지 정보
조회 209회
작성일 20-04-28 17:22
jQuery.BlackAndWhite 플러그인을 이용해 이미지에 흑백 효과를 적용하는 방법을 4단계로 설명한다. jQuery와 플러그인 스크립트를 로드하고, 흑백 처리할 이미지의 래퍼에 bwWrapper 클래스를 지정한 뒤 CSS로 래퍼 스타일을 설정하고, window load 시점에 플러그인을 초기화한다. hoverEffect, intensity, responsive, speed 등 주요 옵션도 소개한다.
1 add jQuery and plug in to the page
<script src="js/jquery.min.js"></script>
<script src="js/jQuery.BlackAndWhite.js"></script>
2 add this class to the wrapper of the image that you want make in Black and White
<div class="bwWrapper">
<img src="path/to/your/image" width="image width" height="image height">
</div>
3 set the wrapper in this way from the css:
.bwWrapper {
position:relative;
display:block;
}
4 initialize the plug in on window load (no $(document).ready()) :
$(window).load(function(){
$('.bwWrapper').BlackAndWhite({
hoverEffect : true, // default true
// set the path to BnWWorker.js for a superfast implementation
webworkerPath : false,
// for the images with a fluid width and height
responsive:true,
// this option works only on the modern browsers ( on IE lower than 9 it remains always 1)
intensity:1,
speed: { //this property could also be just speed: value for both fadeIn and fadeOut
fadeIn: 200, // 200ms for fadeIn animations
fadeOut: 800 // 800ms for fadeOut animations
}
});
}); - 이전글다중 브라우저 호환 CSS 이미지 좌우 반전(미러) 효과 20.04.28
- 다음글MySQL에서 중복 데이터 모두 찾기 (GROUP BY + HAVING) 20.04.28