Menu
CoddyTech

响应式活动门户

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

完成这个门户,同时保留之前的所有功能:居中的 960px 最大宽度网格外壳、视口最小高度、64px 页眉和 48px 页脚;窄屏时的垂直堆叠布局和宽屏时的 160px 侧栏,主内容区域间距为 24px;导航项自动换行,间距为 12px;inline-size 内容限制、在 480px 局部断点处切换为一列或两列卡片、卡片间距为 16px,预订链接底部对齐;响应式表单切换为一列或两列布局、间距为 16px,指南选项占满整行;必填邮箱无效时显示 2px 轮廓,有效时轮廓宽度为零;单选卡片默认为白色且字重正常,仅在选中时变为 #dbeafe 并加粗;双轴滚动的 160px 日程视口、最小宽度固定为 640px 的表格、宽 160px 的首列,以及顶部位置为零的白色 sticky 第 10 层表头,同时保留所有表格语义。现在使用可访问的反向模式,在获得焦点时显示第一个跳过链接,并保留其主要目标和完整可见性。设置 Reserve 的最小宽度和高度为 44px,内容使用 flex 居中,并设置实线 2px 轮廓、4px 偏移,使键盘焦点清晰可见。初始时保留其原生禁用状态:禁用时透明度为 50%,光标为 not-allowed;启用时透明度为 100%,光标为指针。让装饰性预订边框忽略指针事件,同时保留 aria-hidden 属性,这样启用后的原生按钮就能更新提供的计数器。保留完整内容和提供的行为。

challenge icon

挑战

专家

完成这个门户页面,同时保留之前的所有功能:居中的 960px 最大宽度网格外壳、视口最小高度、64px 页眉和 48px 页脚;窄屏时垂直堆叠,宽屏时显示 160px 侧栏,主区域间距为 24px;导航项可换行,间距为 12px;inline-size 内容容器;在 480px 容器断点处,卡片显示为一列或两列,间距为 16px,预约链接贴齐底部;表单响应式地显示为一列或两列,间距为 16px,指南选项占满整行;必填电子邮件字段无效时显示 2px 轮廓,有效时轮廓宽度为零;单选卡片默认白色且字重正常,选中时才变为 #dbeafe 背景和粗体;支持两个方向滚动的 160px 日程视口、最小宽度为 640px 的固定布局表格、宽 160px 的首列,以及位于顶部零位置的白色 sticky 10 级表头,并保留所有表格语义。现在,使用可访问的反向模式,让第一个跳过链接在获得焦点时显示,同时保留它指向 main 的目标并确保完整可见。为 Reserve 设置至少 44px 的宽度和高度,让内容通过 flex 居中,并在键盘焦点可见时显示实线 2px 轮廓,偏移量为 4px。保留按钮原生的初始禁用状态:禁用时不透明度为 50%,光标为 not-allowed;启用时不透明度为 100%,光标为 pointer。让装饰性的预约边框忽略指针事件,同时保持 aria-hidden,这样启用后的原生按钮就能更新提供的计数器。保留完整内容和提供的行为。

保留提供的内容、语义元素和 ID。编辑指定的实用类。编辑后,点击 Run preview 预览,然后点击 Check/Run code 检查结果。提供的 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>
<a id="skip" href="#main" class="sr-only">Skip to event content</a>
<div id="shell" class="w-full max-w-[960px] mx-auto grid min-h-screen grid-rows-[auto_1fr_auto]">
<header id="header" class="h-16 flex items-center px-4 bg-slate-900 text-white"><h1 class="text-xl font-bold">Open Studio Weekend</h1></header>
<main id="main" tabindex="-1" class="grid grid-cols-1 md:grid-cols-[160px_minmax(0,1fr)] gap-6">
<nav id="nav" aria-label="Event sections" class="p-4"><ul id="navList" class="flex flex-wrap gap-3"><li><a href="#sessions">Sessions</a></li><li><a href="#booking">Booking</a></li><li><a href="#schedule">Schedule</a></li></ul></nav>
<div id="content" class="min-w-0 space-y-6 @container">
<section id="sessions" aria-labelledby="sessionsTitle"><h2 id="sessionsTitle" class="text-xl font-bold mb-3">Choose a studio</h2><div id="cards" class="grid grid-cols-1 @min-[480px]:grid-cols-2 gap-4">
<article id="cardA" class="h-56 p-4 rounded-xl bg-slate-100 flex flex-col"><h3 class="h-6 font-bold">Printmaking</h3><p class="h-12">Make a small edition with local artists.</p><a id="cardAAction" href="#booking" class="h-10 mt-auto">Choose printmaking</a></article>
<article id="cardB" class="h-56 p-4 rounded-xl bg-slate-100 flex flex-col"><h3 class="h-6 font-bold">Clay studio</h3><p class="h-12">Explore hand-built forms and texture.</p><a id="cardBAction" href="#booking" class="h-10 mt-auto">Choose clay</a></article>
</div></section>
<section id="booking" aria-labelledby="bookingTitle"><h2 id="bookingTitle" class="text-xl font-bold mb-3">Plan your visit</h2>
<form id="form" class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="name" class="block">Name</label><input id="name" class="w-full h-10 border p-2"></div><div><label for="email" class="block">Email</label><input id="email" type="email" required class="w-full h-10 border p-2 outline-solid outline-0 invalid:outline-2"></div>
<fieldset id="choices" class="col-span-full"><legend>Guide format</legend><label id="digitalCard" class="block p-3 bg-white font-normal has-checked:bg-[#dbeafe] has-checked:font-bold"><input id="digital" type="radio" name="guide"> Digital guide</label><label id="printedCard" class="block p-3 bg-white font-normal has-checked:bg-[#dbeafe] has-checked:font-bold"><input id="printed" type="radio" name="guide"> Printed guide</label></fieldset></form>
</section>
<section id="schedule" aria-labelledby="scheduleTitle"><h2 id="scheduleTitle" class="text-xl font-bold mb-3">Weekend schedule</h2><div id="tableWrap" class="w-full h-40 overflow-auto"><table id="table" class="w-full border-separate border-spacing-0 min-w-[640px] table-fixed"><caption>Studio start times</caption><colgroup><col class="w-40"><col></colgroup><thead><tr><th scope="col" class="sticky top-0 z-10 bg-white">Time</th><th scope="col" class="sticky top-0 z-10 bg-white">Session</th></tr></thead><tbody><tr><th scope="row">09:00</th><td>Welcome</td></tr><tr><th scope="row">09:30</th><td>Printmaking</td></tr><tr><th scope="row">10:00</th><td>Clay studio</td></tr><tr><th scope="row">10:30</th><td>Drawing</td></tr><tr><th scope="row">11:00</th><td>Color workshop</td></tr><tr><th scope="row">11:30</th><td>Studio tour</td></tr><tr><th scope="row">12:00</th><td>Lunch</td></tr><tr><th scope="row">13:00</th><td>Open practice</td></tr></tbody></table></div></section>
<section aria-label="Reservation"><button id="availability" class="my-3 p-2 border">Toggle reservation availability</button><div id="reserveArea" class="relative w-64 h-20"><button id="reserve" disabled class="absolute inset-0 outline-solid bg-blue-100 outline-0">Reserve a place</button><div id="reserveFrame" aria-hidden="true" class="absolute inset-0 border-2 border-blue-700 "></div></div><p>Reservations made: <output id="count">0</output></p></section>
</div></main><footer id="footer" class="h-12 flex items-center px-4 bg-slate-100">Access information is available at the welcome desk.</footer></div>
<script src="./controls.js"></script>
</body></html>
quiz icon自我测试

这节课包含一个小测验。开始学习即可作答,并记录你的进度。

响应式 UI 模式中的所有课