1. Extend2. extend νλ 2κ°μ§ λ°©λ²2-1. classμ΄λ¦ κ°μ Έμ€κΈ°2-2. %placeholder3. μμ : λͺ¨λ¬4. μμ : ν¬ν λ§ν¬ λ°μ€5. μ 체 μ€μ΅ μ½λ
Β
1. Extend
Extendλ μ°κ΄ μλ μμλ€λΌλ¦¬ μ€νμΌ μ½λκ° μ€λ³΅λ κ²½μ°μ μ¬μ©λ©λλ€. μ΄λ―Έ μ€νμΌμ΄ μμ±λ μ νμμ ν΄λμ€λ₯Ό extendνκ±°λ ,
%
λ₯Ό μ¬μ©ν΄μ λ°λ‘ μ€νμΌμ μ μν ν extendνμ¬ μνλ μ νμμκ² μ€νμΌμ μ μ©ν΄ μ€ μ μμ΅λλ€.μλ₯Ό λ€μ΄ asideμμ μ‘΄μ¬νλ 리μ€νΈμ μμλ€μ ν΄λ¦ν λλ§λ€ 보μ¬μ£Όλ λλ‘λ©λ΄μ νλ‘νμ ν΄λ¦νμ λ, νλ‘νκ³Ό κ΄λ ¨λ λ©λ΄λ₯Ό 보μ¬μ£Όλ λλ‘λ©λ΄κ° μλ€κ³ ν©μλ€. μμ λ€μ΄μλ λ΄μ©λ€μ λ€λ₯΄μ§λ§ λλ‘λ©λ΄λΌλ μ°κ΄μ±μ κ°μ§ κ²½μ°μ
λλ€.
Sassλ₯Ό μ¬μ©νμ§ μκ³ μ€νμΌμ μ μ©νλ€λ©΄ μλ‘μ΄ ν΄λμ€λ₯Ό μ ν΄μ μ€λ³΅λλ μ€νμΌμ λ£μ΄μ£Όκ±°λ, κ°κ° λμΌν μ½λλ₯Ό μ μ΄μ μμμ μ€νμΌμ μ μ©ν κ² μ
λλ€. νμ§λ§ Sassμ Extendλ₯Ό μ¬μ©νλ©΄ μ€λ³΅λ μ½λλ₯Ό
@extend
λ₯Ό μ¬μ©νμ¬ λ λ¨μν μ½λλ₯Ό μμ±ν μ μμ΅λλ€. - mixinλ (κ΄κ³ μλ) μ νμμμ μ‘°κΈ λ€λ₯Έ μ€νμΌμ μ μ©ν λ μ¬μ©
- extendλ κ΄κ³ μλ μ νμλ€μ λμΌν μμ€μ½λ μ μ©μ μ¬μ©
2. extend νλ 2κ°μ§ λ°©λ²
2-1. classμ΄λ¦ κ°μ Έμ€κΈ°
κΈ°μ‘΄μ μμ±ν ν΄λμ€ λ΄μ μ½λλ₯Ό κ°μ Έμ¬ μ μμ΅λλ€.
@extend
μ ν΄λμ€ λͺ
μ ν¨κ» μ μΌλ©΄, ν΄λμ€μ μλ μ½λ μ μ²΄κ° extend λ©λλ€.Β
// Scss .profile-user { background-image: url("../assets/user.jpg"); background-size: cover; background-position : 50% 50%; border-radius: 50%; width : 50px; height : 50px; } .comment-user { @extend .profile-user; }
/*CSS*/ .profile-user, .comment-user { background-image: url("../assets/user.jpg"); background-size: cover; background-position : 50% 50%; border-radius: 50%; width : 50px; height : 50px; }
.profile-user
ν΄λμ€λ₯Ό κ°μ§ λ‘κ·ΈμΈ νλ‘ν user μ΄λ―Έμ§ λ°μ€κ° .comment-user
κ° λκΈμ μμ±ν λ userμμ λνλ΄μ£Όλ μ΄λ―Έμ§ λ°μ€μ μ€λ³΅λλ κ²½μ°μ
λλ€. .profile-user
μ½λ μ 체λ₯Ό .comment-user
μκ² extend ν΄μ€λλ€.
Β
β οΈ classλͺ
μ extend νλ κ²½μ° λ€μ€ μ νμ ν΄λμ€λ₯Ό μ¬μ©ν μ μμ΅λλ€. (ex.
.box .container
, .box1 + .box2
)Β
2-2. %placeholder
%
λ‘ μ νμλ₯Ό λ§λλλ€. @extend
λ₯Ό μ¬μ©ν΄μ μμ %placeholder
μ€νμΌ λΈλμ λΆλ¬μ€λ©΄ λ©λλ€.κ·Έλ¦¬κ³ %μ νμλ CSSλ‘ μ»΄νμΌλμ§ μμ΅λλ€.
Β
// Scss %base-button { width: 133px; height: 44px; display: flex; justify-content: center; align-items: center; font-size: 14px; border-radius: 10px; } .follow-button { @extend %base-button; background-color: #ffffff; color: #ff375f; border: 3px solid #ff375f; } .message-button { @extend %base-button; background-color: #ff375f; color: white; }
/*CSS*/ .follow-button, .message-button { width: 133px; height: 44px; display: flex; justify-content: center; align-items: center; font-size: 14px; border-radius: 10px; } .follow-button { background-color: #ffffff; color: #ff375f; border: 3px solid #ff375f; } .message-button { background-color: #ff375f; color: white; }

Β
β οΈExtendλ₯Ό μ¬μ©ν λ, ν΄λμ€λ³΄λ€
%
λ₯Ό μ¬μ©νκΈ°λ₯Ό κΆμ₯ν©λλ€. Β
3. μμ : λͺ¨λ¬
μΉνμ΄μ§ μμμ μμ±λλ μ¬λ¬κ°μ§ λͺ¨λ¬μ λν μ½λμ
λλ€.
%
λ₯Ό μ¬μ©νμ¬ μ€νμΌ λΈλμ λ§λ€κ³ , κ°κ°μ λͺ¨λ¬μ μ€νμΌμ μ μ©ν΄μ€λλ€. // Scss %modal { position: relative; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #fff; border-radius: 6px; } .login-modal { @extend %modal; width: 272px; height: 405px; padding: 10px 20px; } .event-modal { @extend %modal; width: 340px; height: 160px; padding: 18px; }
/*CSS*/ .login-modal, .event-modal { position: relative; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #fff; border-radius: 6px; } .login-modal { width: 272px; height: 405px; padding: 10px 20px; } .event-modal { width: 340px; height: 160px; padding: 18px; }
Β
4. μμ : ν¬ν λ§ν¬ λ°μ€
λ κ°μ divλ ν¬μ€ν
λ§ν¬λ‘ μ΄λνλ κΈ°λ₯μ κ°μ§λ§, μ‘°κΈ λ€λ₯Έ ννμ μ€νμΌμ΄ μ μ©λμ΄ μμ΅λλ€. 곡ν΅λ μ½λλ₯Ό box-frameμΌλ‘ λ¬Άμ΄μ£Όμμ΅λλ€.
Β

// Scss %box-frame { border: 2px solid #bb6bd9; border-radius: 15px; width: 574px; height: 310px; } .phoster-span { @extend %box-frame; span { display: inline-block; border-top: 2px solid #bb6bd9; padding: 16px 0 17px; text-align: center; } } .phoster-none { @extend %box-frame; }
/*CSS*/ .phoster-span, .phoster-none { border: 2px solid #bb6bd9; border-radius: 15px; width: 574px; height: 310px; } .phoster-span span { display: inline-block; border-top: 2px solid #bb6bd9; padding: 16px 0 17px; text-align: center; }
Β