styling <details>
Last updated
Last updated
๐พ replit
/* common settings */
details {
background: hsl(90, 80%, 70%);
/* border */
border: 1px solid #aaa;
border-radius: 4px;
margin-bottom: 8px;
}
summary {
background: hsl(225, 80%, 70%);
border-radius: 3px;
font-weight: bold;
padding: .5em;
}
/* step 1 */
.d1, .d2, .d3, .d4, .d5 {
padding: .5em;
}
.d2 summary, .d3 summary, .d4 summary, .d5 summary {
margin: -.5em -.5em 0;
}
.d3, .d4, .d5 {
padding: .5em .5em 0;
}
.d4[open], .d5[open] {
padding-bottom: .5em;
box-shadow: -2px -2px 5px 0px rgba(0, 0, 0, 0.2) inset;
}
.d5[open] summary {
border-bottom: 1px solid #666;
margin-bottom: .5em;
box-shadow: 2px 2px 5px 0px #404040;
}
<details class="d0" open>
<summary>step 0</summary>
<code><summary></code> ่่ฒใ็ฒ้ซใ<code>padding: .5em;</code><br>
<code><details></code> ็ถ ่ฒ
</details>
<details class="d1" open>
<summary>step 1</summary>
+ <code>details { padding: .5em; }</code><br>
ๆถๅๆ๏ผๅๅจ็ <code>padding</code> ้ฝๆ้ฒๅบไพใ
</details>
<details class="d2" open>
<summary>step 2</summary>
+ <code>summary { margin: -.5em -.5em 0; }</code><br>
<code><summary></code> ไธใๅทฆๅณๅ
ฉๅดๅพๅคๆดๅผต๏ผไฝ้ซๅบฆไธ่ฎใ
ๆถๅๆ๏ผๅฉไธ <code>padding-bottom</code> ้ฝๆ้ฒๅบไพใ
</details>
<details class="d3" open>
<summary>step 3</summary>
/ <code>details { padding: .5em .5em 0; }</code><br>
ไฟฎๆญฃ <code><details></code> ่ฎๅฎๆถๅๆๆฒๆ <code>padding-bottom</code>ใ
</details>
<details class="d4" open>
<summary>step 4</summary>
+ <code>details[open] { padding-bottom: .5em; }</code><br>
ไฟฎๆญฃ <code><details></code> ่ฎๅฎๆ้ๆๆ <code>padding-bottom</code>ใ
</details>
<details class="d5" open>
<summary>step 5</summary>
+ <code>details[open] summary { border-bottom: 1px solid #aaa; margin-bottom: .5em;}</code><br>
ๆ้ๆ๏ผ่ฎ <code><summary></code> ๆๅบ็ท๏ผไธฆ่จญๅฎ <code>margin-bottom</code> ่ไธ้ข็ๅ
งๅฎน้้ใ
</details>