Solution · code-edit

繼承與非繼承屬性

對照完整答案、責任邊界與原因。

Solution 要做什麼

對照完整答案、責任邊界與原因。

本主題檔案:files/style.css

定位:在 Elements 選取 data-inheritance-child,先讀 Computed color 與 border-top-width。

本階段驗收

頁面不會替你修改檔案;請在實作檔完成後重新整理確認。

目前要處理

父層 color 為 rgb(23, 50, 77)、border 為 4px;子層沒有 border-width 宣告。

預期看到

子層 color 與父層相同;border-top-width 初始為 0px,加入明確 inherit 後才成為 4px。

.parent { color: #17324d; border: 4px solid; } .child { border-width: inherit; }

檔案清單

只在本階段資料夾內操作,避免改到其他章節。

證據:實驗 before=0px、after=4px;同一子層的 Computed color 與父層相同

回到主題說明