Making images bigger on my website


Many of my Advent of Patterns blog posts contain visuals that accompany the text. This is different from much of my previous writing which was text-focused; technical guides, poetry, musings.

When looking through my posts, I noticed that some of the details of the images were hard to grasp because they were too small. I was trying to fit the images in a container designed for text: a container whose maximum width was set to be most readable for text, without particular consideration for images.

This got me thinking: how can I make my blog images bigger so they are easier to read?

I decided to follow in the footsteps of the BBC and create a design that lets images be wider than the main content container, but only on the right side.

A BBC article with an image that grows outside the text container

Letting the content grow only on the right side is important because I have a sidebar on the left side of the page. If the image was wider on both sides, the image may overlap with the sidebar. I love the pattern of making an image wider on both sides, but it works best on center-aligned text with plenty of space on either side. My website, on the other hand, uses two columns that are close together.

I had two requirements:

  1. The image should be wider on the right side, and;
  2. The minimum size for the image should be equal to the width of the text column.

I implemented this using the following CSS rule to img tags in my blog posts:

width: clamp(100%, 130%, 65vw);

The CSS clamp attribute lets you specify a minimum, preferred, and maximum value. The browser will then compute which value to use that matches those specifications. In this case, I say that I want images to :

  • Have a minimum width of 100%. This means the maximum size of the content container, which is around 35rem.
  • Have a preferred width of 130%. This allows the image to grow outside the container without getting too big.
  • Have a maximum width of 65vw.

With this one rule, I can have images that are bigger than the parent container that scale at different resolutions.

The following video shows an image scaling as the browser is resized:

This change makes it much easier to see the details in images on bigger screens that were previously confined to a much smaller space.

If you have any suggestions on how to make this feature better, please let me know!



Source link

Visited 1 times, 1 visit(s) today

Related Article

Drinking Tea or Coffee Each Day Could Reduce Mouth And Throat Cancer Risk : ScienceAlert

Topping up your coffee cup throughout the day could provide some protection against common cancers affecting the mouth, throat, and voice box, according to a new study. Researchers in the US gathered more than 25,000 records collated in 14 previous studies, evaluating them collectively to determine what stands out in the diets of individuals with

Advent of Patterns: Status indicators

This article is the twenty-second edition of the Advent of Patterns series. In this series, running from December 1st to December 24th 2024, I will document one design or programming pattern I have noticed recently. Read more about this series. Knowing the status – or “state” – of a system or task is an essential

Looking Glass Coffee Being Replaced by Snohomish Coffee Company

For those who venture out to Downtown Snohomish for a cup of coffee in a warm, unique setting, we have bittersweet news. After seven years, Looking Glass Coffee has decided to shut down. The good news is Snohomish Coffee Company will take over the location and retain some of Looking Glass Coffee’s employees. Here’s a

Why Your Cup Of Coffee Feels More Expensive These Days

Stefania Pelfini, La Waziya Photography/Getty If you’re already feeling exhausted about forking over $7 for a latte, brace yourself: Coffee prices are likely to rise even more in 2025. And while there are differences between arabica and canephora (robusta) coffee species, both are taking a hit next year. Prices

This is the espresso machine Khloe Kardashian is gifting

It’s a tried and true gift for a reason: coffee accessories are simply kitchen essentials, whether you are in the market for a new espresso machine or simply want to contribute to a loved one’s mug collection. When it comes to the former, we are taking inspiration from Khloe Kardashian, whose choice of espresso machine

Western NC coffee truck relocates to Wilmington in the wake of Helene

The Honeybee Cafe truck at the Biggers Market in Wilmington. (Photo: Nate Mauldin/WWAY) WILMINGTON, NC (WWAY) — One of hundreds of businesses left impacted by Hurricane Helene is finding a new home in the Cape Fear.  The Honeybee Cafe is owned and operated by husband-and-wife duo Ted Caudle and Jessica Haugan. The couple was forced

0
Would love your thoughts, please comment.x
()
x