๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
CSS

[CSS] ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹ค์Šต : ๊ฑท๊ธฐ ์• ๋‹ˆ๋ฉ”์ด์…˜ (from.ํ† ๋งคํ† )

by _ํ† ๋งคํ†  2022. 9. 8.
728x90

CSS : ์• ๋‹ˆ๋ฉ”๋‹ˆ์…˜ ๋งŒ๋“ค๊ธฐ : ๊ฑธ์–ด๊ฐ€๋Š” ํ† ๋งคํ† 

์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” CSS์‹ค์Šต์œผ๋กœ ๊ท€์—ฌ์šด ๊ฑท๊ธฐ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜„


border-radius


#1. HTML

๋‹ค์Œ์€ HTML ์ฝ”๋“œ ์ž…๋‹ˆ๋‹ค!

<div class="svgBox timing step">
  <div class="stepbox"></div>
  <span class="stepBtn">
      <a href="#" class="stepBtnStart">Start</a>
      <a href="#" class="stepBtnStop">Stop</a>
  </span>
</div>

#2. CSS

๋‹ค์Œ์€ CSS ์ฝ”๋“œ ์ž…๋‹ˆ๋‹ค!

.step {
  height: 700px;
  background: #fde7ef;
  position: relative;
}
.step .stepbox {
  width: 800px; height: 600px;
  background: url(https://user-images.githubusercontent.com/106949433/188998629-e1cb8ac8-0263-4b69-935d-eacd186c2535.jpg);
  border-radius: 0;
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  animation: ani 1s steps(24, start) infinite;
}
.step .stepbox.start {
  animation-play-state: running;
}
.step .stepbox.stop {
  animation-play-state: paused;
}
@keyframes ani {
  0% {background-position: 0 0;}
  100% {background-position: -19200px 0;}
}
.stepBtn {
  position: absolute; left: 15px; top: 20px;
}
.stepBtn a {
  background: #e16162; color: #fff;
  padding: 10px;
  margin: 3px;
  border-radius: 3px;
}

#3. JavaScript

๋‹ค์Œ์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ž…๋‹ˆ๋‹ค!

$(".stepBtnStart").click(function(e){
  e.preventDefault();
  $(".stepbox").removeClass("stop").addClass("start");
});
$(".stepBtnStop").click(function(e){
  e.preventDefault();
  $(".stepbox").removeClass("start").addClass("stop");
});
728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css