🦁_21.11.19 TIL

BoriΒ·2021λ…„ 11μ›” 20일
1
post-thumbnail

21λ…„ 11μ›” 19일

πŸ“ CSS

πŸ“Ž ν•¨κ»˜ μ½”λ“œ μž‘μ„± - Vending Machine with Media Query

21.11.18-TIL에 μ΄μ–΄μ§€λŠ” λ‚΄μš©μž…λ‹ˆλ‹€.

Vending Machine with Media Query + Grid

πŸ“Ž ν•¨κ»˜ μ½”λ“œ μž‘μ„± - Weniv 둜그인 ν™”λ©΄

21.11.16-TILκ³Ό μ΄μ–΄μ§€λŠ” λ‚΄μš©μž…λ‹ˆλ‹€.

μš”μ†Œμ˜ 높이 μ„€μ •

  • λ˜λ„λ‘ λ†’μ΄λŠ” μ„€μ •ν•˜μ§€ μ•ŠλŠ”λ‹€.
    => μš”μ†Œ λ‚΄μ˜ μ½˜ν…μΈ κ°€ 변동될 κ°€λŠ₯성이 μžˆμœΌλ―€λ‘œ 높이 값을 지정해 λ†“μœΌλ©΄ μ½˜ν…μΈ μ˜ 변동에 따라 UIκ°€ 깨질 수 μžˆλ‹€.

인라인 레벨 μš”μ†Œμ— position / float을 μ§€μ •ν•˜λ©΄ 블둝 레벨둜 바뀐닀.

<a href="#none"> 의 의미

  • νŽ˜μ΄μ§€ 내에 id 값이 none인 곳으둜 이동을 의미
  • <a href="#"> 일 경우, νŽ˜μ΄μ§€κ°€ μƒˆλ‘œκ³ μΉ¨ λ˜λ―€λ‘œ 이 ν˜„μƒμ„ 막기 μœ„ν•΄ <a href="#none">λ₯Ό μ΄μš©ν•˜κΈ°λ„ ν•œλ‹€.
    => <a href="#none">μ—λŠ” μ˜λ―Έκ°€ μžˆλŠ” κ²ƒμ΄λ―€λ‘œ λŒ€μ‹ , <a href="javascript:void(0)"> λ₯Ό μ΄μš©ν•˜λŠ” 것도 μ’‹λ‹€.
    • javascript:void(0)의 의미 : undefinedλ₯Ό λ°˜ν™˜ν•˜λŠ” ν•¨μˆ˜

λ§ˆν¬μ—… μž‘μ„± μˆœμ„œ

  • μ˜λ„μ— 따라 λ§ˆν¬μ—… μž‘μ„± μˆœμ„œκ°€ λ‹€λ₯Ό 수 μžˆλ‹€.
  • 이 μ‹€μŠ΅μ˜ 경우, article.modal-login의 button.btn-close λ₯Ό 둜그인 λ²„νŠΌ 뒀에 μž‘μ„±ν•΄μ„œ article.modal-login 창이 μ—΄λ¦° ν›„ 포컀슀의 이동이
    input[id="inpId"] > input[id="inpPw"] > input[type="checkbox"] > button[class="btn-login"] > button[class="btn-close"] 의 μˆœμ„œλ‘œ μ›€μ§μ΄κ²Œ μž‘μ„±

νŒμ—…

  • νŽ˜μ΄μ§€μ˜ μ½˜ν…μΈ  μœ„μ— λ‚˜νƒ€λ‚˜λŠ” μ°½ λ˜λŠ” λŒ€ν™”μƒμž
  • νŒμ—…μ˜ μ’…νœ΄
    • μ‚¬μš©μžκ°€ νŒμ—…μ˜ λ‚˜λ¨Έμ§€ λΆ€λΆ„κ³Ό μƒν˜Έμž‘μš© ν•  수 μžˆλŠ”μ§€ 여뢀에 따라
      Modal : νŒμ—…μ„ λ‹«κΈ° μ „κΉŒμ§€ νŽ˜μ΄μ§€μ˜ μ½˜ν…μΈ  λΉ„ν™œμ„±ν™”
      Nonmodal : νŒμ—…μ΄ 계속 ν‘œμ‹œλ˜μ–΄ μžˆμ–΄λ„ νŽ˜μ΄μ§€ μ½˜ν…μΈ  ν™œμ„±ν™”

    • 배경의 흐림 처리(dimmed) μ—¬λΆ€
      ligntbox : 배경이 흐림 μ²˜λ¦¬κ°€ λ˜μ–΄μžˆλŠ” 경우
      배경이 흐림 μ²˜λ¦¬κ°€ λ˜μ–΄μžˆμ§€ μ•Šμ€ 경우, νŠΉλ³„ν•œ 이름이 μ—†λ‹€.

      [좜처: Popups: 10 Problematic Trends and Alternatives]

참고 링크
Popups: 10 Problematic Trends and Alternatives

button의 box-sizing κΈ°λ³Έ 값은 border-box

user-select CSS 속성

  • μ‚¬μš©μžκ°€ ν…μŠ€νŠΈλ₯Ό 선택할 수 μžˆλŠ”μ§€ μ—¬λΆ€λ₯Ό μ œμ–΄
/* Keyword values */
user-select: none;
user-select: auto;
user-select: text;
user-select: contain;
user-select: all;
/* Global values */
user-select: inherit;
user-select: initial;
user-select: revert;
user-select: unset;
속성값섀λͺ…
noneν•΄λ‹Ή μš”μ†Œμ™€ ν•˜μœ„ μš”μ†Œμ˜ ν…μŠ€νŠΈλ₯Ό 선택할 수 μ—†μŒ
textν…μŠ€νŠΈ 선택 κ°€λŠ₯

참고 링크
MDN - user-select

πŸ“Ž CSS 싀무 ν…Œν¬λ‹‰

μ»€μŠ€ν…€ input, select λ°•μŠ€

  • λ””μžμΈμ μΈ κ°œμ„±μ„ μ£ΌκΈ° μœ„ν•΄ μ‹€λ¬΄μ—μ„œλŠ” input μš”μ†Œλ‚˜ select λ°•μŠ€μ— λΈŒλΌμš°μ € μŠ€νƒ€μΌκ³Ό λ‹€λ₯΄κ²Œ ν‘œν˜„ν•˜κ³€ ν•œλ‹€.
  • input[type="checkbox"] μ»€μŠ€ν…€
    => μœ„μ˜ <Weniv 둜그인 ν™”λ©΄> μ°Έκ³ 
    => λ‚΄κ°€ μ‹œλ„ν–ˆλ˜ μ½”λ“œμ™€ 비ꡐ
  • select λ°•μŠ€ μ»€μŠ€ν…€
<!DOCTYPE html>
<html lang="ko">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="reset.css" />
    <style>
      h2 {
        margin: 30px;
      }

      .btn-select {
        width: 200px;
        height: 30px;
        background: purple;
        color: #fff;
      }

      .list-member {
        display: none;
        width: 200px;
        height: 30px;
      }

      .list-member.on {
        display: block;
      }

      .btn-select:active + .list-member {
        display: block;
      }

      .list-member li {
        height: 30px;
        width: 200px;
      }

      .list-member li button {
        display: block;
        height: 100%;
        width: 100%;
        background-color: #fff;
        border: 1px solid black;
        border-top: none;
      }

      .list-member li button:hover {
        background-color: bisque;
      }
    </style>
  </head>
  <body>
    <h2>μ…€λ ‰νŠΈ λ°•μŠ€ λ§Œλ“€κΈ°</h2>
    <button class="btn-select">λ‹Ήμ‹ μ˜ μ—μŠ€νŒŒ μ΅œμ•  λ§΄λ²„λŠ”??</button>
    <ul class="list-member">
      <li><button type="button">μΉ΄λ¦¬λ‚˜</button></li>
      <li><button type="button">지저</button></li>
      <li><button type="button">닝닝</button></li>
      <li><button type="button">μœˆν„°</button></li>
    </ul>
    <script>
      const btn = document.querySelector(".btn-select");
      const list = document.querySelector(".list-member");
      btn.addEventListener("click", () => {
        list.classList.toggle("on");
      });
      list.addEventListener("click", (event) => {
        if (event.target.nodeName === "BUTTON") {
          btn.innerText = event.target.innerText;
          list.classList.remove("on");
        }
      });
    </script>
  </body>
</html>

과제 - select box custom

μ†ŒμŠ€μ½”λ“œ 보기

IR(Image Replacement)

λ””μžμΈμ μœΌλ‘œ 보이지 μ•Šμ§€λ§Œ μŠ€ν¬λ¦°λ¦¬λ”λ‚˜ λΈŒλΌμš°μ €λ₯Ό μœ„ν•΄ 정보λ₯Ό μ „λ‹¬ν•˜λŠ” ν…μŠ€νŠΈλ₯Ό μˆ¨κΈ°λŠ” 방법
=> λ‹€μ–‘ν•œ λ°©μ‹μ˜ 해결책이 μžˆλ‹€.

  • μΉ΄μΉ΄μ˜€μ—μ„œ μ‚¬μš©ν•˜λŠ” 방법
/* pc용 - μ‚¬μš©λœ 이미지 λ‚΄ μ˜λ―ΈμžˆλŠ” ν…μŠ€νŠΈμ˜ λŒ€μ²΄ ν…μŠ€νŠΈλ₯Ό μ œκ³΅ν•  λ•Œ */
.ir_pm{
	display:block;
	overflow:hidden;
	Font-size:1px;
	line-height:0;
	text-indent:-9999px;
}

/* mobile용 - μ‚¬μš©λœ 이미지 λ‚΄ μ˜λ―ΈμžˆλŠ” ν…μŠ€νŠΈμ˜ λŒ€μ²΄ ν…μŠ€νŠΈλ₯Ό μ œκ³΅ν•  λ•Œ */
.ir_pm{
	display:block;
	overflow:hidden;
	font-size:1px;
	line-height:0;
	color:transparent;
}

/* μŠ€ν¬λ¦°λ¦¬λ”κ°€ 읽을 ν•„μš”λŠ” μ—†μ§€λ§Œ λ§ˆν¬μ—… ꡬ쑰상 ν•„μš”ν•œ 경우 */
.screen_out {
  overflow: hidden;
  position: absolute;
  width: 0;
  height: 0;
  line-height: 0;
  text-indent: -9999px;
}

/* μ€‘μš”ν•œ 이미지 λŒ€μ²΄ ν…μŠ€νŠΈλ‘œ 이미지가 보이지 μ•Šμ•„λ„ λŒ€μ²΄ ν…μŠ€νŠΈλ₯Ό λ³΄μ—¬μ£Όκ³ μž ν•  λ•Œ */
.ir_wa{
	display:block;
	overflow:hidden;
	position:relative;
	z-index:-1;
	width:100%;
	height:100%
}

  • λ„€μ΄λ²„μ—μ„œ μ‚¬μš©ν•˜λŠ” 방법
 .blind {
	position: absolute;
	clip: rect(0 0 0 0);
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
}

λ„€κ±°ν‹°λΈŒ λ§ˆμ§„μ— λŒ€ν•œ λ…Όλž€

.blind λΌλŠ” 클래슀 λͺ…은 ꢌμž₯ν•˜μ§€ μ•ŠλŠ”λ‹€.

  • bilnd의 의미
    1.눈이 먼, 맹인인
    2.맹인듀
    3.눈이 λ©€κ²Œ λ§Œλ“€λ‹€, μ‹œλ ₯을 μ•—μ•„ κ°€λ‹€ λ“±
  • .sr-only (screen reader only) / .vh (visually hedden) μ‚¬μš©ν•˜κΈ°

읽어보기


마무리

  • μˆ˜μ—… μ‹œκ°„μ— λ‚΄κ°€ λͺ°λžλ˜ λ‚΄μš©λ“€μ΄ λ‚˜μ˜€λ©΄ λ”°λ‘œ λ©”λͺ¨ν•΄λ†“κ³  TIL μž‘μ„±ν•˜λ©΄μ„œ 쑰금 더 μžμ„Ένžˆ 찾아보곀 ν•œλ‹€.
    => κ°„λ‹¨ν•˜λ‹€κ³  μƒκ°ν–ˆλ˜ λ‚΄μš©μ΄ 싀은 κ½€ κΉŠμ€ λ‚΄μš©μ΄μ–΄μ„œ λ‹Ήν™©μŠ€λŸ½κΈ°λ„ ν•˜μ§€λ§Œ 찾아보길 μž˜ν–ˆλ‹€. λΏŒλ“―!
  • 3μ£Όμ°¨ κΈˆμš”μΌ! 주말에 ν•΄μ•Όν•  λͺ©λ‘μ„ μž‘μ„±ν•΄λ†“μ•˜λŠ”λ° λ‹€ ν•  수 μžˆκ² μ§€?
    => μ΅œλŒ€ν•œ ν•  수 μžˆλ„λ‘ 해야지

0개의 λŒ“κΈ€