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

Nou Camp under reconstruction

Barcelona: Why is first home game not at Nou Camp?

ByElizabeth Conway Spanish football reporter Marcus Rashford could play his first home game of the season for Barcelona in a stadium far smaller than the one he was expecting. Despite hopes that Barcelona would begin the defence of their title at the newly renovated Nou Camp stadium, they will instead play their first home match

Saul 'Canelo' Alvarez (right) throws a right-hand punch at opponent Terence Crawford in Las Vegas fight on September 14, 2025

Terence Crawford stuns Canelo Alvarez in Las Vegas to become undisputed world super-middleweight champion | Boxing News

Terence Crawford produced a masterclass performance against Canelo Alvarez to become the undisputed super-middleweight champion and make history in the process. In front of 70,000 fans at Allegiant Stadium in Las Vegas, Crawford, who moved up two weight divisions, claimed a unanimous decision victory to claim the WBO, WBC, IBF and WBA super-middleweight belts –

A woman looking confused looking at a phone and a debit card in either hand.

Could Buying SoFi Technologies Stock Today Set You Up for Life?

The digital bank is rapidly gaining share in an important financial market. Banking is slowly moving into the 21st century. Out are branches, checks, and physical currency. In are mobile banking applications, digital money transfers, and online-only banks. SoFi Technologies (SOFI 2.27%) is turning into the leading digital bank in the United States. By offering

Jefferies Downgrades ICON Public Limited (ICLR) to Hold From Buy

ICON Public Limited Company (NASDAQ:ICLR) is one of the best cheap stocks to buy for beginners. On September 9, Jefferies analyst David Windley downgraded ICON Public Limited Company (NASDAQ:ICLR) to Hold from Buy, bringing the price target down to $175 from $220. ICON Public Limited Company (ICLR): Among Small-Cap Healthcare Stocks Hedge Funds is Buying

12-year cap for Hong Kong ride-hailing cars will let most continue: minister

12-year cap for Hong Kong ride-hailing cars will let most continue: minister

The government’s proposal to extend the age limit for ride-hailing vehicles from seven to 12 years will allow most cars currently providing the service to continue operating when the new law takes effect, Hong Kong’s transport minister has explained. Secretary for Transport and Logistics Mable Chan on Sunday also said it would be inappropriate to