search
HomeWeb Front-endCSS TutorialAnd the Oscar Goes to … Coding a Chronology Component

Earlier this year, a friend of mine shared a massive poster he had been working on for the Copenhell festival in Copenhagen, Denmark. The poster, an impressive 2 x 12 meters, showcased a detailed chronology of significant cultural events from the past 50 years, with a particular focus on heavy metal rock — fitting, as Copenhell is a festival dedicated to that genre!

And the Oscar Goes to … Coding a Chronology Component

I really loved the design — which featured a unique "snake timeline" layout. Inspired by this, I decided to create my own version using HTML and CSS, but with a twist — focusing on the "Best Picture" Oscar winners from 1972 onwards… and yes, I've seen them all!


Let's start by creating some semantic markup. This HTML will provide the structure for our timeline and will look good even without any CSS styling applied:

<ol>
  <li value="1972">
    <article>
      <img src="/static/imghwm/default1.png" data-src="1972.jpg" class="lazy" alt="The Godfather">
      <h4 id="The-Godfather">The Godfather</h4>
      <small>A powerful crime saga following the Corleone family's rise and near fall within organized crime</small>
    </article>
  </li>
</ol>

... and we get:

And the Oscar Goes to … Coding a Chronology Component

As you can see, the timeline looks quite presentable even with just the default browser styles!

Note: The value-attribute is only valid for

  • -tags when the parent is an ordered list,
      .
  • We'll use ordered lists for each "column" in the timeline, and wrap those those in:

    <div class="ui-chronology">
      <ol>...</ol>
    </div>
    

    Styling the list-items

    Each list item is a grid with two columns. The black line and the year are represented by ::before and ::after pseudo-elements, respectively. Both pseudo-elements are placed in the same grid cell (first column) using a 'grid stack' technique (grid-area: 1 / 1), which allows multiple elements to overlap within the same grid area:

    li {
      display: grid;
      grid-template-columns: max-content 1fr;
    
      &::before { /* Vertical line */
        content: "";
        background: #000;
        grid-area: 1 / 1;
        margin-inline: auto;
        width: var(--bdw);
      }
    
      &::after { /* Year */
        align-self: start;
        background-color: #000;
        border-radius: .175em;
        color: #FFF;
        content: attr(value);
        font-size: clamp(1rem, 0.2857rem + 2.2857vw, 2rem);
        font-weight: 900;
        grid-area: 1 / 1;
        padding-inline: .5ch;
        width: 5ch;
      }
    }
    

    I'm gonna jump ahead a bit, and show how 3

      -tags look next to each other. We're almost there:

      And the Oscar Goes to … Coding a Chronology Component

      What we're missing, are the "wavy connectors". To create the 'wavy connectors' between timeline entries, I used a small 'hack' involving a 'dummy'

    1. tag. This tag acts as a placeholder for the decorative connectors, ensuring they are positioned correctly without affecting the rest of the timeline’s structure:
      
      
    2. These will be placed at the very top and bottom of each

        , and since they're for decorative purposes only, I added aria-hidden="true".

        Now, the CSS for the connectors is quite complex, so I'll just show the structure with a few inline comments below — see the final CodePen-demo at the end and dive into the code:

        ol {
          &:nth-of-type(odd) {
            li[value="0"] {
              &:last-of-type {
                /* Bottom Left Corner */
                &::before { }
              }
            }
            /* FIRST COLUMN ONLY */
            &:first-of-type {
              li[value="0"]:first-of-type {
                /* Hide Top Left Corner */
                &::before { display: none; } 
              }
            }
            &:not(:first-of-type) { 
              li[value="0"] {
                &:first-of-type {
                /* Top Left Corner: Reverse */
                  &::before { }
                }
              }
            }
        
            &:last-of-type li[value="0"]:last-of-type i {
              ...
            }
            /* Round dot at the end of the last list */
            &:last-of-type li[value="0"]:last-of-type i::after { ... }
          }
        
          /* EVEN COLUMNS */
          &:nth-of-type(even) {
            li[value="0"] {
              &:first-of-type {
                /* Top Left Corner */
                &::before { ... }
              }
              &:last-of-type {
                /* Bottom Left Corner: Reverse */
                &::before { ... }
              }
            }
          }
        }
        

        Phew! A lot of :first-of-type / :last-of-type-logic!

        Additionally, all the CSS is also using logical properties, such as:

        border-block-width: 0 var(--bdw);
        border-inline-width: var(--bdw) 0;
        border-end-start-radius: var(--bdrs);
        

        Why is that? If you're working on a site with a right-to-left text-direction (dir="rtl"), everything will look weird, if you use properties that include left or right in the name (such as padding-left).

        With logical properties, everything will look fine, when you switch text-direction:

        And the Oscar Goes to … Coding a Chronology Component

        How cool is that! Now, let's add some more columns:

        And the Oscar Goes to … Coding a Chronology Component

        Notice how the "final round dot" automatically moves to the last column!

        And that wraps up this tutorial.

        Demo

        Please open the demo in a new window and resize to see the columns re-flow.

    The above is the detailed content of And the Oscar Goes to … Coding a Chronology Component. For more information, please follow other related articles on the PHP Chinese website!

    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    The Slideout FooterThe Slideout FooterApr 09, 2025 am 11:50 AM

    A fascinating new site called The Markup just launched. Tagline: Big Tech Is Watching You. We’re Watching Big Tech. Great work from Upstatement. The

    Pages for LikesPages for LikesApr 09, 2025 am 11:47 AM

    I posted about parsing an RSS feed in JavaScript the other day. I also posted about my RSS setup talking about how Feedbin is at the heart of it.

    Recreating the CodePen Gutenberg Embed Block for Sanity.ioRecreating the CodePen Gutenberg Embed Block for Sanity.ioApr 09, 2025 am 11:43 AM

    Learn how to create a custom CodePen block with a preview for Sanity Studio, inspired by Chris Coyier’s implementation for Wordpress’ Gutenberg editor.

    How to Make a Line Chart With CSSHow to Make a Line Chart With CSSApr 09, 2025 am 11:36 AM

    Line,  bar, and pie charts are the bread and butter of dashboards and are the basic components of any data visualization toolkit. Sure, you can use SVG

    Programming Sass to Create Accessible Color CombinationsProgramming Sass to Create Accessible Color CombinationsApr 09, 2025 am 11:30 AM

    We are always looking to make the web more accessible. Color contrast is just math, so Sass can help cover edge cases that designers might have missed.

    How We Created a Static Site That Generates Tartan Patterns in SVGHow We Created a Static Site That Generates Tartan Patterns in SVGApr 09, 2025 am 11:29 AM

    Tartan is a patterned cloth that’s typically associated with Scotland, particularly their fashionable kilts. On tartanify.com, we gathered over 5,000 tartan

    A Follow-Up to PHP TemplatingA Follow-Up to PHP TemplatingApr 09, 2025 am 11:14 AM

    Not long ago, I posted about PHP templating in just PHP (which is basically HEREDOC syntax). I'm literally using that technique for some super basic

    Creating a Modal Image Gallery With Bootstrap ComponentsCreating a Modal Image Gallery With Bootstrap ComponentsApr 09, 2025 am 11:10 AM

    Have you ever clicked on an image on a webpage that opens up a larger version of the image with navigation to view other photos?

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    VSCode Windows 64-bit Download

    VSCode Windows 64-bit Download

    A free and powerful IDE editor launched by Microsoft

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    SecLists

    SecLists

    SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

    SublimeText3 English version

    SublimeText3 English version

    Recommended: Win version, supports code prompts!

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools