Dev Blog

스크립트 & 소스코드 공유

실무에서 유용하게 쓰는 스크립트와 코드 조각을 블로그 게시판으로 저장하고 공유합니다.

5건의 글

jQuery Incremental Counter - 숫자가 올라가는 카운터 예제

jquery.incremental-counter 플러그인을 이용해 숫자가 점점 올라가는 애니메이션 카운터를 만드는 예제다. jQuery와 플러그인 파일을 로드하고, .incremental-counter 요소에 data-value 속성으로 목표 숫자를 지정한 뒤 incrementalCounter()를 호출하면 페이지 진입 시 숫자가 증가하며 표시된다.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Incremental Counter Plugin Demo</title>

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="jquery.incremental-counter.js"></script>

<style>
body { background-color:#384047;}
.container { margin:150px auto; max-width:500px; text-align:center}
h1 { margin-bottom:30px; color:#fff; text-align:center;}
.incremental-counter{margin:1%}
.incremental-counter .num {
background: #eee;
border: 1px solid #fff;
border-radius: 4px;
color: #384047;
display: inline-block;
height: 64px;
line-height: 62px;
margin: 0 4.5px;
position: relative;
text-align: center;
top: -1px;
width: 50px;
font-size: 45px;
font-size: 3.72625em;
font-weight: 700;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45);
font-family: "Open Sans",Arial,Helvetica,sans-serif;
}
.incremental-counter .num::before {
background: #384047;
content: "";
display: block;
height: 1px;
left: -1px;
margin: -0.5px 0 0;
position: absolute;
right: -1px;
top: 50%;
width: auto;
}
</style>
</head>

<body>

<div class="container">
<div class="incremental-counter" data-value="55650"></div>
<div class="incremental-counter" data-value="360"></div>
<div class="incremental-counter" data-value="36200"></div>
</div>
<script>
$(".incremental-counter").incrementalCounter();
</script>

</body>
</html>

CSS 애니메이션 예제 - 요소 움직임·전환 효과

CSS 애니메이션으로 요소를 부드럽게 움직이고 전환 효과를 주는 예제를 보여주는 CodePen 데모다. @keyframes로 위치·크기·색상 등의 변화를 정의하고 transition을 함께 사용해 자연스러운 모션을 구현한다. 버튼·배너·배경 등에 바로 적용할 수 있는 스타일이며 duration과 easing 조절 방법도 함께 확인할 수 있다.

See the Pen Untitled by H J (@H-J-the-typescripter) on CodePen.

CSS로 텍스트가 가로로 흐르는 롤링(스크롤) 효과 만들기

텍스트가 가로 방향으로 흐르는 롤링 효과를 CSS로 구현한 CodePen 예제다. @keyframes에서 요소를 왼쪽으로 translateX 이동시키고 infinite 애니메이션을 적용해, 공지사항이나 배너 문구가 화면을 가로질러 반복적으로 흐르도록 만든다. 속도 조절과 일시정지도 CSS로 처리할 수 있다.

See the Pen Untitled by H J (@H-J-the-typescripter) on CodePen.

CSS animation으로 텍스트 색상이 번지는 효과 만들기

CSS @keyframes를 이용해 텍스트 색상이 번지듯 변하는 애니메이션 예제다. h2 요소에 animation: spread 1s ease-in-out infinite alternate를 적용하고, @keyframes spread의 to 단계에서 색상을 파란색에서 빨간색으로 전환한다. 제목 텍스트에 간단히 적용할 수 있는 전체 코드를 제공한다.

<style type="text/css">
H2{text-align:center; font-size:5em; color:blue; animation:spread 1s ease-in-out infinite alternate }

@keyframes spread{
to{
color:red;
}
}
</style>

<h2>미래를 향한 기업</h2>

tsparticles로 연결되는 입자(파티클) 배경 만들기

tsparticles 라이브러리를 이용해 입자들이 서로 선으로 연결되며 움직이는 애니메이션 배경을 만드는 방법이다. CDN 스크립트 로드와 배경 컨테이너 HTML, 입자 개수·색상·크기·투명도·연결선, 마우스 호버 repulse와 클릭 push 반응, 배경 색상 등을 설정하는 CSS와 JavaScript 코드를 제공한다.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/tsparticles.min.js"></script>
<div id="tsparticles"></div>
/* ---- reset ---- */
body {
margin: 0;
font: normal 75% Arial, Helvetica, sans-serif;
}
canvas {
display: block;
vertical-align: bottom;
}
/* ---- tsparticles container ---- */
#tsparticles {
position: absolute;
width: 100%;
height: 100%;
background-color: #0d47a1;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
}
tsParticles.load("tsparticles", {
fpsLimit: 60,
particles: {
number: {
value: 80,
density: {
enable: true,
value_area: 800
}
},
color: {
value: "#ff0000",
animation: {
enable: true,
speed: 20,
sync: true
}
},
shape: {
type: "circle",
stroke: {
width: 0,
color: "#000000"
},
polygon: {
nb_sides: 5
}
},
opacity: {
value: 0.5,
random: false,
anim: {
enable: false,
speed: 3,
opacity_min: 0.1,
sync: false
}
},
size: {
value: 3,
random: true,
anim: {
enable: false,
speed: 20,
size_min: 0.1,
sync: false
}
},
line_linked: {
enable: true,
distance: 100,
color: "random",
opacity: 0.4,
width: 1,
triangles: {
enable: true,
color: "#ffffff",
opacity: 0.1
}
},
move: {
enable: true,
speed: 6,
direction: "none",
random: false,
straight: false,
out_mode: "out",
attract: {
enable: false,
rotateX: 600,
rotateY: 1200
}
}
},
interactivity: {
detect_on: "canvas",
events: {
onhover: {
enable: true,
mode: "repulse"
},
onclick: {
enable: true,
mode: "push"
},
resize: true
},
modes: {
grab: {
distance: 400,
line_linked: {
opacity: 1
}
},
bubble: {
distance: 400,
size: 40,
duration: 2,
opacity: 0.8,
speed: 3
},
repulse: {
distance: 200
},
push: {
particles_nb: 4
},
remove: {
particles_nb: 2
}
}
},
retina_detect: true,
background: {
color: "#000000",
image: "",
position: "50% 50%",
repeat: "no-repeat",
size: "cover"
}
});


Let's create something great together.

프로젝트 문의 및 견적 요청은 언제든 환영합니다.