beforeμ after κ°μμμ μ νμ css
::before μμμ 맨 μμ λ°°μΉνλ λ§ν¬μ
μ μλ κ°μμμ
::after μμμ 맨 λ€μ λ°°μΉνλ λ§ν¬μ
μ μλ κ°μμμ
:::before μ ::afterμ λ§ν¬μ
ν κ²½μ°,
νμλ‘ {content:""; } μ΄ λ€μ΄κ°μΌ νλ€.
λ¬Έμλ₯Ό νμν λλ λ°μ΄ν μμ λ¬Έμλ₯Ό λ£μΌλ©΄ λλ€.
λ€λ₯Έ κΈ°λ₯μ νλ©΄μ λ¬Έμκ° μμ κ²½μ° λΉλ°μ΄νλ§ λ£μΌλ©΄ λλ€.
κ·Έλ¦¬κ³ inline μμ±μ κ°μ§κ³ μμΌλ―λ‘ ν¬κΈ° κ°μ μ£Όλ €λ©΄ {display: inline-block; }μ΄λ {display: block; }μμ±μ λ£μ΄μ€μΌνλ€.
.test1::before {display: block; content:"";}
μμ λ₯Ό ν΅ν΄μ νμΈν΄λ³΄μ.
<!doctype html>
<html>
<head>
<meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=0,maximum-scale=10,user-scalable=yes">
<title>κ°μμμ μ νμ</title>
<style>
.test1 {margin:0 auto; max-width:600px; padding:50px; border:1px solid #ccc;}
.test1::before {display:block; content: ""; background: pink;padding: 20px;}
.test1::after {display:block; content: ""; background: skyblue;padding: 20px;}
.yyy::before {display:block; content: "μ";}
.yyy::after {display:block; content: "λ€";}
.test2 {margin: 0 auto; width: 500px; border:1px solid red; height:50px;; position: relative;}
.test2::before {display:block; content: ""; width:2px; height:50px; background: #000; transform: rotate(45deg); position: absolute; top:0; left:100px;}
.test2::after {display:block; content: ""; width:2px; height:50px; background: #000; transform: rotate(-45deg); position: absolute; top:0; left:100px;}
</style>
</head>
<body>
<div class="test1">
<p class="yyy">*********</p>
</div>
<br>
<div class="test2">
</div>
</body>
</html>
.test1μ ::beforeλ₯Ό μ μ©ν κ²½μ°,
.test1μ΄ κ°μ§κ³ μλ λΈλ μμ 맨 μμ μμ±μ΄ μ μ©λλ€.
μ¬κΈ°μ ν·κ°λ¦¬μ§ λ§μ.
.test1 λΈλ μμ μ μ©λλ κ²μ΄ μλλ€.
.test1μ΄ ν¬ν¨νκ³ μλ 컨ν
μΈ λ§¨ μμ μμΉνκ² λλ€.
::afterλ₯Ό μ μ©ν κ²½μ°,
.test1μ΄ ν¬ν¨νκ³ μλ 컨ν
μΈ μ 맨 λ€μ μμΉνκ² λλ€.
.yyy::beforeκ³Ό .yyy:afterμ μ΄μ©ν΄μ .yyyκ° κ°μΈκ³ μλ 컨ν
μΈ μ 맨 μμ "μ"κ³Ό 맨 λ€μ "λ€"κΈμλ₯Ό νμνλ€.
κ²Ήμ³μ§ κ²½μ° ::beforeλ 맨 λ€μ λμ΄κ² λλ©°, ::afterμ 맨 μμ λμ΄κ² λλ€.
.test2μ κ²½μ° νλ²κ±° λ©λ΄λ₯Ό ν΄λ¦νμ λ λμ€λ μ°½λ«κΈ° X λ²νΌμ ::beforeμ ::afterλ‘ λ§λ€μλ€.
<!doctype html>
<html>
<head>
<meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=0,maximum-scale=10,user-scalable=yes">
<title>κ°μμμ μ νμ</title>
<style>
.test2 {margin: 0 auto; width: 500px; border:1px solid red; height:50px;; position: relative;}
.test2::before {display:block; content: ""; width:2px; height:50px; background: #000; transform: rotate(45deg); position: absolute; top:0; left:100px;}
.test2::after {display:block; content: ""; width:2px; height:50px; background: #000; transform: rotate(-45deg); position: absolute; top:0; left:100px;}
</style>
</head>
<body>
<div class="test2">
</div>
</body>
</html>
'HTML&CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
white-space css(div μ€λ°κΏ λ°©μ§ css) (2) | 2021.12.06 |
---|---|
background css μΆμ½, νλ²μ μ°λ λ°©λ², μ€μ¬μ μ¨λ³΄μ (1) | 2021.12.01 |
λ°μν λ°±κ·ΈλΌμ΄λ μ΄λ―Έμ§ λ§λ€κΈ° (0) | 2021.11.18 |
μ΄λ―Έμ§ 맡 λ§λ€κΈ°(μ΄λ―Έμ§ 맡 μ’νκ° μ½κ² μ°ΎκΈ°) (0) | 2021.06.16 |
λ¬΄λ£ μμ΄μ½ μ¬μ΄νΈ - BEST 8κ° μ¬μ΄νΈπ (0) | 2021.06.08 |