Menu
CoddyTech

Parent State Groups

Part of the Fundamentals section of Coddy's Tailwind CSS journey. Lesson 44 of 55.

Put group on a card and group-hover:opacity-50 on a child caption. Hovering anywhere on that parent can change the caption, even when the pointer is not directly over the caption.

<article class="group">
  <div class="group-hover:opacity-50">Museum sample</div>
</article>

The group marker identifies the ancestor whose state matters. A plain hover: on the child listens only to the child. Keep the caption present at rest so pointer movement is not required to discover its meaning.

challenge icon

Challenge

Medium

In the supplied grouped event card, keep the caption at 75 percent opacity normally and change it to 30 percent while the parent is hovered.

Keep the supplied content and element IDs. Edit the HTML utility classes or the requested CSS. Click Run preview to refresh the preview after edits, then use Check/Run code to grade your work.

Try it yourself

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Practice studio</title><link rel="stylesheet" href="./styles.css"></head><body>
<div aria-hidden="true" class="h-8"></div><article id="parent_target" class="group p-8 border"><span id="pad_target" class="block h-8">Card cover</span><div id="target" class="">View event</div></article>
</body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals