Making the new Salter Cane website

Making the new Salter Cane website

With the release of a new Salter Cane album I figured it was high time to update the design of the band’s website.

Here’s the old version for reference. As you can see, there’s a connection there in some of the design language. Even so, I decided to start completely from scratch.

I opened up a text editor and started writing HTML by hand. Same for the CSS. No templates. No build tools. No pipeline. Nothing. It was a blast!

And lest you think that sounds like a wasteful way of working, I pretty much had the website done in half a day.

Partly that’s because you can do so much with so little in CSS these days. Custom properties for colours, spacing, and fluid typography (thanks to Utopia). Logical properties. View transitions. None of this takes much time at all.

Because I was using custom properties, it was a breeze to add a dark mode with prefers-color-scheme. I think I might like the dark version more than the default.

The final stylesheet is pretty short. I didn’t bother with any resets. Browsers are pretty consistent with their default styles nowadays. As long as you’ve got some sensible settings on your body element, the cascade will take care of a lot.

There’s one little CSS trick I think is pretty clever…

The background image is this image. As you can see, it’s a rectangle that’s wider than it is tall. But the web pages are rectangles that are taller than they are wide.

So how I should I position the background image? Centred? Anchored to the top? Anchored to the bottom?

If you open up the website in Chrome (or Safari Technical Preview), you’ll see that the background image is anchored to the top. But if you scroll down you’ll see that the background image is now anchored to the bottom. The background position has changed somehow.

This isn’t just on the home page. On any page, no matter how tall it is, the background image is anchored to the top when the top of the document is in the viewport, and it’s anchored to the bottom when you reach the bottom of the document.

In the past, this kind of thing might’ve been possible with some clever JavaScript that measured the height of the document and updated the background position every time a scroll event is triggered.

But I didn’t need any JavaScript. This is a scroll-driven animation made with just a few lines of CSS.

@keyframes parallax {
    from {
        background-position: top center;
    }
    to {
        background-position: bottom center;
    }
}
@media (prefers-reduced-motion: no-preference) {
        html {
            animation: parallax auto ease;
            animation-timeline: scroll();
        }
    }
}        

This works as a nice bit of progressive enhancement: by default the background image stays anchored to the top of the viewport, which is fine.

Once the site was ready, I spent a bit more time sweating some details, like the responsive images on the home page.

But the biggest performance challenge wasn’t something I had direct control over. There’s a Spotify embed on the home page. Ain’t no party like a third party.

I could put loading="lazy" on the iframe but in this case, it’s pretty close to the top of document so it’s still going to start loading at the same time as some of my first-party assets.

I decided to try a little JavaScript library called “lazysizes”. Normally this would ring alarm bells for me: solving a problem with third-party code by adding …more third-party code. But in this case, it really did the trick. The library is loading asynchronously (so it doesn’t interfere with the more important assets) and only then does it start populating the iframe.

This made a huge difference. The core web vitals went from being abysmal to being perfect.

I’m pretty pleased with how the new website turned out.

This was originally published on my own website, which is awesome.

要查看或添加评论,请登录

Jeremy Keith的更多文章

  • The web on mobile

    The web on mobile

    Here’s a post outlining all the great things you can do in mobile web browsers today: Your App Should Have Been A…

    3 条评论
  • Re-dConstruct

    Re-dConstruct

    From 2005 to 2015 Clearleft ran the dConstruct event here in Brighton (with one final anniversary event in 2022). I had…

  • Deep Black Water

    Deep Black Water

    Back in July 2023 I went into the studio along with the rest of Salter Cane. We had been practicing a whole lot of new…

    2 条评论
  • Research By The Sea

    Research By The Sea

    I’m going to be hosting Research By The Sea on Thursday, February 27th right here in Brighton. I’m getting very excited…

    2 条评论
  • Conference line-ups

    Conference line-ups

    When I was looking back at 2024, I mentioned that I didn’t give a single conference talk (though I did host three…

    39 条评论
  • Announcing UX London 2025

    Announcing UX London 2025

    Is it too early to start planning for 2025 already? Perhaps. But you might want to add some dates to your calender:…

  • That was UX London 2024

    That was UX London 2024

    UX London 2024 is done …and it was magnificent! It’s always weird when an event like this moves from being something in…

    1 条评论
  • Browser support

    Browser support

    There was a discussion at Clearleft recently about browser support. Rich has more details but the gist of it is that…

    1 条评论
  • Declarative Design

    Declarative Design

    A presentation given at the final An Event Apart in San Francisco, as well as at Pixel Pioneers in Bristol, Web Summer…

    1 条评论
  • UX London 2024 closing keynotes

    UX London 2024 closing keynotes

    Alright, so last week I gave you the low-down on each day of this year’s UX London: Tuesday, June 18th focuses on UX…

    1 条评论

社区洞察

其他会员也浏览了