๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
[๊ฐœ๋ฐœ] Practice/HTML CSS

[HTML/CSS] ์ข…์ด์ฒ˜๋Ÿผ ๋’ค์ง‘ํžˆ๋Š” ํ”„๋กœํ•„์‚ฌ์ง„ ๋งŒ๋“ค๊ธฐ

by Connecting-the-dots 2022. 3. 2.
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ก ์‹ค์Šต ํฌ์ธํŠธ!

 

  • ์˜ˆ์ „์— ์ด๋ ฅ์„œ๋ฅผ ํฌํŠธํด๋ฆฌ์˜ค๋กœ ๋งŒ๋“ค์–ด๋ณผ๊นŒ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ์„ ๋•Œ, ๋งˆ์šฐ์Šค์˜ค๋ฒ„๋ฅผ ํ•˜๋ฉด ์ด๋ฏธ์ง€๊ฐ€ ๋’ค์ง‘ํžˆ๋ฉด์„œ ๊ธ€์ด ๋‚˜์˜ค๋Š”...์ด๋Ÿฐ ๊ธฐ๋Šฅ์„ ์›ํ•œ ์ ์ด ์žˆ์—ˆ๋Š”๋ฐ ๋งˆ์นจ! ๋”ฑ ๋ฐฐ์šฐ๊ฒŒ ๋˜์—ˆ๋‹ค.
  • ์ด๋ฏธ์ง€๊ฐ€ ๋’ค์ง‘ํ˜€๋„ ์•ž๋ฉด์˜ ์ด๋ฏธ์ง€๊ฐ€ ๋’ท๋ฉด์— ๋น„์ณ๋ณด์ด๊ณ , ํšŒ์ „์‹œ์ผฐ์„ ๋•Œ ๊ธ€์”จ๋„ ๊ฐ™์ด ํšŒ์ „๋˜๋Š” ๋“ฑ ์ƒ๊ฐ์ง€๋„ ๋ชปํ•œ ๋ถ€๋ถ„์—์„œ ๋‚œํ•ญ์„ ๊ฒช์—ˆ๋‹ค.
  • ์ œ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์ƒ๊ฐ๋ณด๋‹ค ์—ฐ์Šต์„ ์ข€ ๋งŽ์ด ํ•ด์•ผํ•  ๊ฒƒ ๊ฐ™๋‹ค.

๐Ÿ’œ HTML

<div class="flip-outer"> // ์ „์ฒด์ ์ธ ํ‹€
   <div class="flip-inner"> // ํ‹€ ๋‚ด๋ถ€(์•ž, ๋’ท๋ฉด์„ ๊ฐ€์ง)
       <!-- ์•ž๋ฉด : ์ด๋ฏธ์ง€ -->
       <img src="./img/profile.png" class="front">
       <!-- ๋’ท๋ฉด : ๋‚ด์šฉ -->
       <div class="back">
           <h4>Front-end Developer</h4>
           <p>Bak Seoyun</p>
       </div>
   </div>
</div>

๐Ÿ’œ CSS

.flip-outer {
  width: 300px;
  height: 300px;
}

.flip-inner {
  width: 100%;
  height: 100%;
  position: relative; /* front, back ๋ถ€๋ถ„์˜ position ์„ absolute ๋กœ ์ฃผ๊ธฐ ์œ„ํ•ด position : relative ์‚ฌ์šฉ */
  transition: all 1s;
  transform-style: preserve-3d; /* ํšŒ์ „ํ•  ๋•Œ 3d ์ฒ˜๋Ÿผ ๋™์ž‘ํ•˜๊ฒŒ ํ•˜๊ธฐ */
}

.flip-inner:hover {
  transform: rotateY(180deg);
  cursor: pointer;
}

.front {
  width: 100%;
  height: 100%;
  position: absolute; /* position ์„ absolute ๋กœ ์ฃผ์–ด์•ผ ์•ž๋’ค๋กœ ๋ฐฐ์น˜๊ฐ€ ๊ฐ€๋Šฅ */
  backface-visibility: hidden; /* ๋’ท๋ฉด์— ๊ทธ๋ฆผ ์•ˆ ๋น„์น˜๊ณ  ๊ธ€์”จ๋งŒ ๋‚˜์˜ค๊ฒŒ ํ•˜๊ธฐ */
  z-index: 1; /* ์•ž๋ฉด์˜ ๊ทธ๋ฆผ์ด ์•ˆ๋ณด์ด๋Š” ๊ฒฝ์šฐ ์ถ”๊ฐ€ */
}

.back {
  width: 100%;
  position: absolute;
  text-align: center;
  transform: rotateY(180deg); /* Y์ถ•์„ ๊ธฐ์ค€์œผ๋กœ 180๋„ ํšŒ์ „์‹œ์ผฐ์„ ๋•Œ ๊ธ€์”จ๊ฐ€ ์ œ๋Œ€๋กœ ๋ณด์ด๋ ค๋ฉด, ๋’ท๋ฉด์ด ๋ณด์ผ ๋•Œ๋Š” ๊ธ€์”จ๋„ Y์ถ• ๊ธฐ์ค€์œผ๋กœ ๋’ค์ง‘ํ˜€์žˆ์–ด์•ผ ํ•จ */
  background: orange;
  height: 100%;
  border-radius: 50%;
  display: flex; /* ๊ธ€์ž๋ฅผ ์„ธ๋กœ ๊ธฐ์ค€์œผ๋กœ 1์ค„๋กœ ๊ฐ€์šด๋ฐ ์ •๋ ฌํ•˜๊ธฐ ์œ„ํ•ด flex ์†์„ฑ ์‚ฌ์šฉ */
  flex-direction: column;
  justify-content: center;
}
728x90
๋ฐ˜์‘ํ˜•