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 2 times, 1 visit(s) today

Related Article

חוויית VR במרכז האקספו בהנגז'ו

Will China’s AI boom rewrite the global order?

Chinese AI models are closing the gap with Western models, with a growing number of companies and organizations now integrating them into their operations. This poses not only a competitive threat to American and other Western firms, but also a geopolitical risk: if this trend gains global traction, it could give the Chinese Communist Party

Hong Kong should have ‘real’ dialogue on same-sex partnership proposal: LGBTQ groups

Hong Kong should have ‘real’ dialogue on same-sex partnership proposal: LGBTQ groups

LGBTQ organisations in Hong Kong have called for “real consultations” on a government-proposed framework to recognise same-sex partnerships, even as widespread opposition from lawmakers threatens to derail the plan. The groups said on Sunday that the reaction from legislators was “not surprising” but the “hostility” had prompted some people to leave the city altogether. In

Hakan Calhanoglu Inter Milan

Galatasaray still haven’t made Inter an offer for Hakan Calhanoglu

Galatasaray reportedly still have not made Inter Milan an offer to sign midfielder Hakan Calhanoglu this summer. This according to today’s print edition of Rome-based newspaper Corriere dello Sport, via FCInterNews. Hakan Calhanoglu seems to be caught with one foot out the door at Inter Milan, and one foot still inside. Galatasaray have been signalling

YouTube Video

From Economic Roller-Coaster To Mystery Deal

US-China relations have been on a roller-coaster it would seem with President Trump announcing across the board tariffs of 145% on Chinese imports, followed by the latter imposing retaliatory tariffs of 125%. “In  the last week of June it was announced that a new deal had been signed and the contours of that deal …

Happy person sitting with phone and laptop.

What Are 5 Great Growth Stocks to Buy That Are Down 20% or More?

While the market has returned to new highs, not every growth stock has rebounded at the same pace. Five stocks still down 20% or more from all-time highs that look attractive are Advanced Micro Devices (AMD -0.45%), GitLab (GTLB 2.73%), e.l.f. Beauty (ELF 1.21%), Dutch Bros (BROS 1.74%), and Cava Group (CAVA 4.96%). Let’s look

Two investors at home look at something on a laptop.

Billionaire Michael Platt Just Made a Move that Would Please Warren Buffett

Billionaire investors have proven their talents over the years by producing big returns for clients and for themselves. They don’t all make the same moves at the same times, though — and sometimes they pivot in completely opposite directions. For example, in the past year, Stanley Druckenmiller of the Duquesne Family Office sold all of

Club World Cup semifinal power rankings: Battle for the trophy intensifies

Club World Cup semifinal power rankings: Battle for the trophy intensifies

Over the past few weeks, the first-ever 32-team Club World Cup has whittled itself down to a tidy quartet. This isn’t a midsummer UEFA Champions League either, with Fluminense giving a non-European challenger against a few of the modern era’s usual suspects: Chelsea, Real Madrid and PSG. Are they in position to give Gianni Infantino

France's Macron to visit UK as Starmer eyes 'reset' with EU

France’s Macron to visit UK as Starmer eyes ‘reset’ with EU

France’s Macron to visit UK as Starmer eyes ‘reset’ with EU PARIS, July 6, 2025 (BSS/AFP) – French President Emmanuel Macron is to begin a state visit to the United Kingdom on Tuesday, where he is set to address the British Parliament and co-chair a meeting on Ukraine as London seeks to strengthen its ties

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