๐Ÿ“ƒ ๐Ÿ–Š๏ธ ์™„์ „ํžˆ ๋ฐ˜์‘ํ•˜๋Š” HTML+CSS ์Šคํ‹ฐ์ปค ๋ฉ”๋ชจ

10975 ๋‹จ์–ด htmlshowdevwebdevcss
์†Œ๊ทœ๋ชจ ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•ด HTML๊ณผ CSS๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํ‹ฐ์ปค ๋ฉ”๋ชจ๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.



์Šคํ‹ฐ์ปค ๋ฉ”๋ชจ์˜ ๋ชจ์–‘๊ณผ ๋Š๋‚Œ์„ ์žฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์€ ๊ณก๋ฅ ์„ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค. ๋‚˜๋Š” ์ด๊ฒƒ์„ ๋‹ฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด SVG์™€ clipPath๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ณก๋ฅ ์„ ์ง€์›ํ•˜๋ ค๋ฉด ์•ฝ๊ฐ„์˜ ์กฐ๋ช… ํšจ๊ณผ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์„ ํ˜• ๊ทธ๋ผ๋””์–ธํŠธ๋กœ ์ด๊ฒƒ์„ ๋‹ฌ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ๊ฐ€์žฅ ์–ด๋ ค์šด ์ ์€ ๊ทธ๋ฆผ์ž๋ฅผ ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉํ–ฅ์œผ๋กœ ๋ฐฐ์น˜ํ•˜๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค. ์Šคํ‹ฐ์ปค๊ฐ€ ์‹ค์ œ๋กœ ๋ฒฝ์— ๊ทธ๋ฆผ์ž๋ฅผ ๋“œ๋ฆฌ์šฐ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์—ฌ์•ผ ํ•˜์ง€๋งŒ ์Šคํ‹ฐ์ปค ๋ถ€๋ถ„์ด ๋ฒฝ์— ์ง์ ‘ ๋‹ฟ๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ๋ฆผ์ž๋ฅผ ๋“œ๋ฆฌ์šฐ์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์‘๋‹ต์„ฑ์€ ๋ฐฑ๋ถ„์œจ ๋ฐ ์ ์‘ํ˜• ๊ธ€๊ผด ํฌ๊ธฐ๊ฐ€ ์žˆ๋Š” ํŒจ๋”ฉ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆผ์ž ํฌ๊ธฐ์™€ ์œ„์น˜ ์ง€์ •๋„ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐฑ๋ถ„์œจ ๋‹จ์œ„๋กœ ์ธํ•ด ์„œ๋กœ ๋‹ค๋ฅธ ๋ทฐํฌํŠธ์—์„œ ๋‹ค๋ฅด๊ฒŒ ๋™์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๋งˆํฌ์—…์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

<div class="sticky-container">
  <div class="sticky-outer">
    <div class="sticky">
      <svg width="0" height="0">
        <defs>
          <clipPath id="stickyClip" clipPathUnits="objectBoundingBox">
            <path
              d="M 0 0 Q 0 0.69, 0.03 0.96 0.03 0.96, 1 0.96 Q 0.96 0.69, 0.96 0 0.96 0, 0 0"
              stroke-linejoin="round"
              stroke-linecap="square"
            />
          </clipPath>
        </defs>
      </svg>
      <div class="sticky-content">
        Hello! I'm a<br>
        sticky note!
      </div>
    </div>
  </div>
</div>


๋‹ค์Œ์€ CSS์ž…๋‹ˆ๋‹ค.

/* Some positioning and ratios */
.sticky-container {
  max-width: 270px;
  position: relative;
}

.sticky-outer {
  display: flex;
  padding-top: 92.5925926%;
  position: relative;

  width: 100%;
}

.sticky {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Shadow behind the sticky note */
.sticky:before {
  box-shadow: -2px 2px 15px 0 rgba(0, 0, 0, 0.5);
  background-color: rgba(0, 0, 0, 0.25);
  content: '';
  width: 90%;
  left: 5px;
  height: 83%;
  position: absolute;
  top: 30%;
}

/* The sticky note itself */
.sticky-content {
  background: linear-gradient(
    180deg,
    rgba(187, 235, 255, 1) 0%,
    rgba(187, 235, 255, 1) 12%,
    rgba(170, 220, 241, 1) 75%,
    rgba(195, 229, 244, 1) 100%
  );
  width: 100%;
  height: 100%;

  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Kalam', cursive;
  font-size: 1rem;

  clip-path: url(#stickyClip);
}

/* Add responsiveness */
@media screen and (min-width: 640px) {
  .sticky:before {
    height: 79%;
    width: 90%;
  }
  .sticky-content {
    font-size: 1.25rem;
  }
}

@media screen and (min-width: 768px) {
  .sticky:before {
    height: 75%;
    width: 90%;
  }
  .sticky-content {
    font-size: 1.5rem;
  }
}

@media screen and (min-width: 1024px) {
  .sticky:before {
    height: 73%;
    width: 90%;
  }
  .sticky-content {
    font-size: 1.875rem;
  }
}


๊ทธ๊ฒŒ ๋‹ค์•ผ, ์ข‹์€ ์ฃผ๋ง ๋˜์„ธ์š”!


์—ฌ๊ฐ€ ์‹œ๊ฐ„์— ๊ธฐ์ˆ  ๊ธฐ์‚ฌ๋ฅผ ์”๋‹ˆ๋‹ค. ์ด ๊ฒŒ์‹œ๋ฌผ์„ ์žฌ๋ฏธ์žˆ๊ฒŒ ์ฝ์œผ์…จ๋‹ค๋ฉด buying me a coffee์„ ๊ณ ๋ คํ•˜์‹ญ์‹œ์˜ค!

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ