Skip to content

Archive

CSS

11 articles
CSS 04 Sep 2026 10 min read

Debug CSS z-index with Stacking Contexts

A z-index bug often looks irrational. You give a menu z-index: 9999, yet a header still covers it. Increasing the number to 999999 changes nothing. The natural conclusion is that z-index is unreliable. It is not. The mistake is usually comparing numbers that belong to different stacking contexts. A stacking context is a local coordinate system for painting overlapping elements. Descendants are ordered inside that context, and then the entire context participates as one unit in its parent’s stacking order. A child with a huge z-index cannot escape a parent that is painted below a sibling context.

CSS 02 Sep 2026 6 min read

Practical Conditional Styling with the CSS :has() Selector

CSS traditionally selects an element from information about that element or its ancestors. The :has() relational pseudo-class adds a different capability: an element can match according to relative selectors evaluated from that element. This makes many parent-aware and sibling-aware styles possible without adding state classes solely for presentation. The useful mental model is not “select the parent,” but “select this element if a related element matches a condition.” Read :has() from the outside in Consider a card that should use a different layout when it contains a direct image child:

CSS 02 Sep 2026 4 min read

Individual CSS Transform Properties for Maintainable UI Motion

For years, CSS transforms were commonly written as one transform declaration: .card { transform: translateY(-4px) scale(1.02); } That works, but it couples every transform operation to one property. A component that needs to change only its translation must either reproduce the existing scale or overwrite it.

CSS 02 Sep 2026 4 min read

CSS Logical Properties for International and Reusable Layouts

Traditional CSS often describes layout with physical directions: left, right, top, and bottom. That is intuitive until the same component must work in a right-to-left language or a different writing mode. Logical properties describe layout relative to the flow of text. Instead of saying “left padding,” you can say “padding at the inline start.” The browser maps that intent to the correct physical edge. Think in block and inline axes CSS logical layout uses two axes:

CSS 01 Sep 2026 3 min read

Use CSS Subgrid to Align Nested Components

CSS Grid normally creates an independent track system for every grid container. That isolation is useful until nested components need to align with columns or rows defined by an ancestor. subgrid lets a nested grid reuse those tracks instead of guessing their sizes. Modern evergreen browsers support subgrid, making it practical for production layouts where cross-component alignment matters. The problem with independent nested grids Consider a product list where every card contains a title, description, price, and action. If each card uses its own rows, the buttons move vertically when descriptions have different lengths.

CSS 01 Sep 2026 3 min read

CSS Logical Properties for International and Flexible Layouts

CSS traditionally describes spacing and borders with physical directions such as left, right, top, and bottom. That works until a component must support right-to-left text or a writing mode where the inline direction is not horizontal. Logical properties describe layout relative to the flow of text. They make components more adaptable without maintaining a second set of directional overrides. Physical versus logical directions In a typical English document, the inline axis runs from left to right and the block axis runs from top to bottom. Logical properties name those axes instead of assuming screen directions.

CSS 01 Sep 2026 5 min read

CSS Cascade Layers for Predictable Specificity

Specificity problems often appear gradually. A stylesheet starts with simple class selectors, then an override needs a more specific selector, then another rule adds an ID or !important, and eventually changing one component requires understanding a long chain of accidental precedence. Cascade layers give authors a separate way to express priority. Instead of making selectors stronger, you define which groups of rules are allowed to win. What a cascade layer changes CSS already resolves conflicts using several inputs, including origin, importance, layer order, specificity, and source order. @layer adds an explicit ordering step for normal author rules.

CSS 01 Sep 2026 5 min read

Container Queries for Component-Level Responsive CSS

Media queries answer a viewport-level question: how wide is the browser? Reusable components often need a different answer: how much space does this component have where it was placed? CSS container queries solve that problem. A card can render compactly in a sidebar and switch to a horizontal layout in a wide content area without knowing either page layout in advance. Why viewport breakpoints leak layout assumptions Consider a reusable article card. A media query might switch it to two columns when the viewport exceeds 900 pixels:

CSS 03 Sep 2025 8 min read

Building a Responsive Mega Menu Navbar with Tailwind CSS and Alpine.js

Navigation is one of the most important components of a website. For sites with many categories, a mega menu can present many options cleanly inside a large dropdown. This article shows how to build a responsive navbar with mega menus using Tailwind CSS for styling and Alpine.js for interactive behavior. Main Navbar Features Desktop Navigation Main links: Home, Products, Services, About, Contact Mega menus for Products and Services A regular dropdown for About Mobile Navigation

CSS Updated 02 Sep 2025 2 min read

Create a Hover Zoom Effect with Tailwind CSS

Small interactions can make a web page feel more polished. One simple example is a zoom effect when the pointer hovers over an image. With Tailwind CSS, you can build it with utility classes instead of writing a separate CSS rule. 1. HTML Structure Here is a basic example: <div class="relative"> <img src="https://picsum.photos/500/300.webp" alt="Image" class="hover:scale-125 transition-transform duration-300 ease-in-out"> </div> 2. What Do the Tailwind Classes Do? relative → gives the wrapper relative positioning. It does not create the zoom effect itself, but it is useful if you later add positioned overlays. hover:scale-125 → scales the image to 125% while it is hovered. transition-transform → animates changes to the transform property. duration-300 → makes the transition last 300 milliseconds. ease-in-out → starts and ends the transition gradually for a smoother feel. 3. Customize It Use a larger scale:

CSS Updated 02 Sep 2025 2 min read

Build a Masonry Gallery with a Zoom Effect in Tailwind CSS

Have you seen photo galleries where images are arranged like a brick wall in a masonry layout and smoothly zoom when you hover over them? You can build that effect with only a few Tailwind CSS utility classes. In this article, we will create a responsive masonry gallery with a hover zoom effect. 1. Gallery HTML Structure A few div elements with Tailwind classes are enough to create the layout: