Blog

  • Fluid Scaling: The Core Concept

    In modern web design, creating layouts that look perfect on every screen size—from massive 4K monitors to small mobile phones—is a significant challenge. Traditional approaches rely heavily on fixed pixel values (e.g., width: 300px) combined with numerous media queries (@media (max-width: 768px) { ... }) to snap elements into different layouts at specific breakpoints.

    This “snapping” effect can feel abrupt and often leads to elements looking slightly off-proportion between breakpoints.

    Fluid scaling (often called proportional scaling) solves this by ensuring that elements smoothly grow and shrink in direct proportion to the viewport’s width.

    Think of your website like a rubber band. As you stretch the window (on a desktop) or compress it (on a phone), the elements inside should stretch and compress seamlessly along with it.

    The Mathematics of Fluid Scaling

    At the heart of our fluid scaling system is a simple mathematical ratio. It ties a specific pixel value to the width of the screen. In CSS, the full width of the screen is represented by 100vw (Viewport Width, meaning 100% of the visible screen).

    The core formula is: ( Target Pixel Value ) × ( 100vw / Base Design Width )

    Example Scenario

    Let’s say our designer created a mockup in Figma with an artboard width of 1920px (our Base Design Width). In that design, a specific heading has a font size of 32px (our Target Pixel Value).

    We want that heading to be exactly 32px only when the screen is exactly 1920px wide. If the screen shrinks perfectly in half to 960px, we want the font size to intuitively shrink in half to 16px. This guarantees the design always looks exactly like the mockup, no matter the device.

    Plugging it into the formula: 32 * ( 100vw / 1920 )

    1. The ratio (100vw / 1920) essentially figures out “what percentage of the base design width is the current screen?”
    2. If the user’s screen is 1920px wide, 100vw equals 1920px. The ratio becomes (1920 / 1920) = 1. Then, 32 * 1 = 32px.
    3. If the user’s screen is 960px wide, 100vw equals 960px. The ratio becomes (960 / 1920) = 0.5. Then, 32 * 0.5 = 16px.

    The CSS Variable (--wp--custom--fxx)

    To avoid writing (100vw / 1920) everywhere in our CSS, we abstract this ratio into a global CSS custom property (variable) named --wp--custom--fxx.

    This variable holds the exact mathematical ratio. In our case, the value it holds is exactly calc(100vw / 1920).

    Defining the Variable in WordPress (theme.json)

    If you are building a modern WordPress block theme, you don’t define this variable in a standard style.css file. Instead, you define it in the theme.json configuration file.

    Doing it this way is highly beneficial because it allows WordPress to automatically make this variable available inside the Gutenberg Site Editor. This means your content creators will see the exact same fluid scaling in the backend editor as the visitors see on the live site.

    To add this to your theme, insert the following into the settings object of your theme.json:

    {
      "$schema": "https://schemas.wp.org/trunk/theme.json",
      "version": 3,
      "settings": {
        "custom": {
          "fxx": "calc(100vw / 1920)"
        }
      }
    }

    Note: When you define a custom object named fxx inside settings.custom, WordPress automatically generates a CSS variable and prefixes it with --wp--custom--. This is where --wp--custom--fxx physically originates and how it gets injected into the <body> of your website.

    Once defined, this variable makes the math cleaner everywhere else. Anywhere we want to scale a value based on the 1920px design, we simply multiply our target pixel value by this variable using the calc() function:

    .my-element {
      /* Scales a 300px box down proportionally on smaller screens */
      width: calc(300 * var(--wp--custom--fxx));
    }

    In the next part, we’ll look at how the SCSS 

    fxx() function makes writing this even easier and cleaner.

  • Creating Outlined Text Effects with CSS Text Stroke

    Typography plays a crucial role in modern web design. With the right styling, even a simple text element can serve as a strong visual anchor for your layout. One effective yet often overlooked technique is the use of CSS text stroke, which allows developers to add outlines around text — creating clean, bold, and visually distinctive headlines without relying on images.

    The -webkit-text-stroke CSS property lets you define both the width and color of a text outline. It serves as a shorthand for the individual properties -webkit-text-stroke-width and -webkit-text-stroke-color.

    This article demonstrates how to achieve a text stroke effect using CSS, along with a practical example.

    The HTML Structure

    We start with a minimal HTML setup:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>HTML + CSS</title>
        <link rel="stylesheet" href="styles.css" />
      </head>
      <body>
        <h1>Jaspreet Kaur</h1>
      </body>
    </html>
    

    This example keeps the structure intentionally simple. The focus is on applying style to the <h1> element, which serves as our primary visual element.

    Applying the CSS

    The visual transformation occurs entirely through CSS:

    @import url("https://fonts.googleapis.com/css2?family=Zain:ital,wght@0,200;0,300;0,400;0,700;0,800;0,900;1,300;1,400&display=swap");
    
    h1 {
      -webkit-text-stroke: 2px #0d9a66;
      text-stroke: 2px #0d9a66;
      font-size: 100px;
      line-height: 1;
      color: #fff;
      font-family: "Zain", sans-serif;
      font-weight: 700;
    }

    Key Properties

    • Font Import: The @import rule pulls in the Zain typeface from Google Fonts, chosen for its contemporary yet readable style.
    • Text Stroke: The property -webkit-text-stroke (and its unprefixed form, where supported) defines the outline of the text. In this case, a 2px stroke in #0d9a66 — a rich green — outlines the white text for a clean, modern appearance.
    • Typography Settings: Setting a large font size (100px) and bold weight (700) ensures the stroke effect is clearly visible.

    The Result

    The result is a bold heading displaying “Jaspreet Kaur” with a clean green outline. This simple effect gives the text a logo-like presence — elegant yet minimal.

    Such an approach is highly effective for:

    • Hero or landing page headlines
    • Personal branding and portfolio headers
    • Section titles that require visual emphasis

    By using pure CSS, developers can create scalable, resolution-independent text effects that perform well across devices.

    Browser Support and Fallbacks

    The text-stroke property is currently supported in most WebKit-based browsers (including Chrome, Edge, and Safari). However, it may not render in Firefox or some older browsers.

    For broader compatibility, a fallback using text-shadow can simulate a similar outline:

    text-shadow: 2px 2px 0 #0d9a66;

    While this method doesn’t replicate the crisp edges of text stroke, it ensures visual consistency across more environments.

    Conclusion

    The -webkit-text-stroke property offers a simple yet powerful way to enhance typography on the web. By combining it with modern fonts and thoughtful color contrast, designers can create text that feels polished and professional without increasing page weight. While this method doesn’t replicate the crisp edges of text stroke, it ensures visual consistency across more environments.

    This technique demonstrates how minimal CSS can yield high visual impact — reinforcing that great design often comes from subtle, well-executed details.