버블버블 효과 제이쿼리입니다~
[ HTML ]
<div class='bubbles'></div>
[ CSS ]
.center-outer { display: table; width: 100%; height: 100%; }
.center-inner { display: table-cell; vertical-align: middle; text-align: center; }
.bubbles { display: inline-block; font-family: arial; position: relative; }
.bubbles h1 { position: relative; margin: 1em 0 0; font-family: 'arial'; font-size:50px; color:#fff; z-index: 2; }
.dh-bubble { position: absolute; border-radius: 100%; bottom: 10px; background-color: #fff; z-index: 1; }
[ Java Script ]
jQuery(document).ready(function($){
var bArray = [];
var sArray = [4,6,8,10];
for (var i = 0; i < $('.bubbles').width(); i++) {
bArray.push(i);
}
function randomValue(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
setInterval(function(){
var size = randomValue(sArray);
$('.bubbles').append('<div class="dh-bubble" style="left: ' + randomValue(bArray) + 'px; width: ' + size + 'px; height:' + size + 'px;"></div>');
$('.dh-bubble').animate({
'bottom': '100%',
'opacity' : '-=0.6'
}, 3000, function(){ $(this).remove() });
}, 350);
});
'웹관련 > JavaScript-Jquery' 카테고리의 다른 글
[자바스크립트] 이벤트함수에서 e와 window.Event 둘다 사용하는 이유 (0) | 2017.10.30 |
---|---|
[자바스크립트] 익스,크롬,사파리,파이어폭스 즐겨찾기 추가하기 (0) | 2017.05.26 |
[자바스크립트] 고정된 배경을 패럴랙스 하는방법 (0) | 2017.03.29 |
[자바스크립트] 마우스 휠 이벤트를 활용하자 (0) | 2016.12.13 |
[자바스크립트] 윈도우 팝업이 차단되어있을경우 경고창 띄우기 (0) | 2016.11.16 |
댓글