预约面板
本课属于 Coddy Tailwind CSS 学习旅程的“响应式 UI 模式”单元。第 53 课,共 55 课。
保留步骤 1 中的外壳、响应式导航栏和自动换行的导航,以及步骤 2 中的内容容器、局部响应式双卡片网格和底部对齐的预约链接,并保留所有尺寸和间距。预约表单在视口宽度小于 768px 时显示为一列,在更宽的视口中显示为两列等宽布局,两个方向的间距均为 16px。指南字段集占据表单的整行。保留标签和原生约束。必填邮箱无效时使用实线 2px 轮廓,有效时轮廓宽度为零。每个原生单选选项卡片未选中时为白色且使用常规字重,选中其后代元素后变为 #dbeafe 并加粗;更改选项后,之前的卡片恢复原样。
挑战
专家保留第 1 步中的外框、自适应导航栏和可换行导航,以及第 2 步中的内容容器、局部自适应双卡片网格和底部对齐的预约链接,并保留它们的所有尺寸和间距。在视口宽度小于 768px 时,将预约表单设为单列;在更宽的视口中设为两列等宽布局,两个方向的间距均为 16px。引导手册字段集占据整行。保留标签和原生约束。必填邮箱无效时显示实线 2px 轮廓,有效时轮廓宽度为 0。每个原生单选项卡片在未选中时为白色且字重正常,选中后变为 #dbeafe 且字重加粗;更改选项后,之前的卡片会恢复原样。
保留提供的内容、语义元素和 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>
<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"><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"></div>
<fieldset id="choices" class=""><legend>Guide format</legend><label id="digitalCard" class="block p-3 "><input id="digital" type="radio" name="guide"> Digital guide</label><label id="printedCard" class="block p-3 "><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-hidden"><table id="table" class="w-full border-separate border-spacing-0 "><caption>Studio start times</caption><colgroup><col class="w-40"><col></colgroup><thead><tr><th scope="col" class="">Time</th><th scope="col" class="">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>
这节课包含一个小测验。开始学习即可作答,并记录你的进度。