Menu
CoddyTech

回顾:分层界面

本课属于 Coddy Tailwind CSS 学习旅程的“响应式 UI 模式”单元。第 45 课,共 55 课。

challenge icon

挑战

困难

构建一张具有局部层叠关系的预约卡片。卡片根元素应设置为相对定位并创建独立的层叠上下文。添加一个覆盖整张卡片的装饰边框,层叠级别为 20,设置 aria-hidden,并忽略指针事件。内容区域保持定位,层叠级别为 10;状态徽章的层叠级别为 30,距离顶部和右侧各 8px。保留提供的顶部内边距和原生 Reserve 按钮;点击按钮时必须更新提供的计数器。

保留提供的内容、语义元素和 ID。编辑指定的实用类。编辑完成后,点击“运行”预览,然后点击“检查”或“运行代码”对结果评分。提供的 JavaScript 只能读取,不能修改。

亲手试试

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<article id="card" class="w-80 h-40 relative"><div id="frame" aria-hidden="true" class="absolute inset-0 border-4 z-20"></div><section id="content" class="relative pt-10 z-0"><h2>Weekend studio</h2><button id="action">Reserve</button></section><span id="badge" class="static">Open</span></article><output id="count">0</output>
<script src="./controls.js"></script>
</body></html>

响应式 UI 模式中的所有课