CSS3 3D º¯È¯ ±â´ÉÀ» »ç¿ëÇÏ¿© À̹ÌÁö, ¹è°æ À̹ÌÁö, Youtube, Vimeo, HTML5 Video µîµî ...
¸¹Àº HTML ¿ä¼Ò¿¡ ºÎµå·¯¿î Parallax Effect ¸¦ Ãß°¡ÇÏ´Â jQuery Plugin ÀÔ´Ï´Ù.
»ç¿ë¹ýÀº »ý°¢º¸´Ù ½±½À´Ï´Ù.
1. ±âº»ÀûÀ¸·Î jQuery Plugin À̹ǷΠjQuery ¸¦ È£ÃâÇØ ÁÖ¼Å¾ß ÇÕ´Ï´Ù.
2. Script È£Ãâ ÇØ ÁÖ¼¼¿ä.
<!-- Jarallax -->
<script src="jarallax/dist/jarallax.min.js"></script>
<!-- Include it if you want to use Video parallax -->
<script src="jarallax/dist/jarallax-video.min.js"></script>
3. HTML ¿ä¼Ò´Â ¾Æ·¡Ã³·³ ÇÏ½Ã¸é µË´Ï´Ù.
<!-- Background Image Parallax -->
<div class="jarallax">
<img class="jarallax-img" src="<background_image_url_here>" alt="">
Your content here...
</div>
<!-- Background Image Parallax with <picture> tag -->
<div class="jarallax">
<picture class="jarallax-img">
<source media="..." srcset="<alternative_background_image_url_here>">
<img src="<background_image_url_here>" alt="">
</picture>
Your content here...
</div>
<!-- Alternate: Background Image Parallax -->
<div class="jarallax" style="background-image: url('<background_image_url_here>');">
Your content here...
</div>
4. CSS ¸¦ ¼±¾ðÇÏ¿© º¯°æÇÒ ÀÏÀÌ ÀÖ´Ù¸é Ç÷¯±×ÀΠȣÃâÀü¿¡ ¹Ì¸® ¼±¾ðÇϽðųª
jarallax CSS ÆÄÀÏ¿¡ ³Ö¾îµÎ¼Åµµ µË´Ï´Ù.
.jarallax {
position: relative;
z-index: 0;
}
.jarallax > .jarallax-img {
position: absolute;
object-fit: cover;
/* support for plugin https://github.com/bfred-it/object-fit-images */
font-family: 'object-fit: cover;';
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
5. Ç÷¯±×ÀΠȣÃâ ¹æ½Ä¿¡ ´ëÇؼ ¾È³» ÇÕ´Ï´Ù.
- data attribute (µ¥ÀÌÅÍ ¼Ó¼º ¼³Á¤ÇÏ´Â ¹æ½Ä)
Á¦°øÇÏ´Â ¿É¼ÇÀ» ¸ðµÎ ¼Ó¼ºÀ¸·Î ³ÖÀ¸¼Åµµ µË´Ï´Ù.
( ¿É¼ÇÀº ¾Æ·¡¿¡ ´Ù½Ã ÷ºÎ ÇÕ´Ï´Ù. )
<!-- Background YouTube Parallax -->
<div class="jarallax" data-jarallax-video="https://www.youtube.com/watch?v=ab0TSkLe-E0">
Your content here...
</div>
<!-- Background Vimeo Parallax -->
<div class="jarallax" data-jarallax-video="https://vimeo.com/110138539">
Your content here...
</div>
<!-- Background Self-Hosted Video Parallax -->
<div class="jarallax" data-jarallax-video="mp4:./video/local-video.mp4,webm:./video/local-video.webm,ogv:./video/local-video.ogv">
Your content here...
</div>
- JavaScript ¹æ½Ä
import { jarallax, jarallaxVideo } from 'jarallax';
jarallaxVideo();
jarallax(document.querySelectorAll('.jarallax'), {
speed: 0.2,
videoSrc: 'https://www.youtube.com/watch?v=ab0TSkLe-E0'
});
<div class="jarallax"></div>
6. Options ¾È³»
Name |
Type |
Default |
Description |
type |
string |
scroll |
scroll, scale, opacity, scroll-opacity, scale-opacity. |
speed |
float |
0.5 |
Parallax effect speed. Provide numbers from -1.0 to 2.0. |
imgSrc |
path |
null |
Image url. By default used image from background. |
imgElement |
dom / selector |
.jarallax-img |
Image tag that will be used as background. |
imgSize |
string |
cover |
Image size. If you use <img> tag for background, you should add object-fit values, else use background-size values. |
imgPosition |
string |
50% 50% |
Image position. If you use <img> tag for background, you should add object-position values, else use background-position values. |
imgRepeat |
string |
no-repeat |
Image repeat. Supported only background-position values. |
keepImg |
boolean |
false |
Keep <img> tag in it's default place after Jarallax inited. |
elementInViewport |
dom |
null |
Use custom DOM / jQuery element to check if parallax block in viewport. More info here - Issue 13. |
zIndex |
number |
-100 |
z-index of parallax container. |
disableParallax |
RegExp / function |
- |
Disable parallax on specific user agents (using regular expression) or with function return value. The image will be set on the background. |
disableVideo |
RegExp / function |
- |
Disable video load on specific user agents (using regular expression) or with function return value. The image will be set on the background. |
¿µ»óÀ» ÀÌ¿ëÇÏ´Â °æ¿ì Àú»ç¾ç PC ¿¡¼´Â ´Ù¼Ò ¹ö¹÷ÀÓÀÌ ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù.
|