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

Farewell to Ferrari for these celebrities

If you think of Ferrari, what’s the first thing that comes to your mind? Apart from its characteristic red color, this brand represents prestige, elegance and exclusivity. So, to reinforce these ideas, the brand is coming up with strict rules on who can own one of its most sought-after vehicles, and celebrities are in the

Marco Rubio targets China for "abusing trade practices, stealing US technology, and flooding US with fentanyl"

Dalai Lama’s re-incarnation is China’s internal affair: Chinese envoy to India

China today reacted to India’s assertion of ‘upholding religious freedom’ of Tibetans in choosing the successor to 14th Dalai Lama Tenzin Gyatso. China’s Ambassador to India Xu Feihong posted a message on social media platform X on Sunday saying “the reincarnation and succession of the Dalai Lama is inherently an internal affair of China… No

Android users pumped with features as the OnePlus 13 update arrives

What you need to know The latest firmware for the OnePlus 13 enables remote control support for Windows PCs, allowing users to access files and control their computer from their OnePlus 13. The handset users also gain a Game Camera for live screenshots and flashback recording during gameplay. The update also includes a Speaker Cleaner

Article image:Newcastle Eye Seri A Signing as Defensive Reinforcements Become Crucial

Newcastle Eye Seri A Signing as Defensive Reinforcements Become Crucial

Newcastle’s Scalvini Pursuit Signals Ambition But Carries Risk Reinforcements Needed for Dual Front Battle Newcastle United’s interest in Atalanta’s Giorgio Scalvini is as persistent as it is ambitious. With both Premier League and Champions League football on the Magpies’ calendar, defensive reinforcements are not just advisable, they are essential. Chronicle Live reports that Newcastle’s admiration

UDINE, ITALY - APRIL 11: Theo Hernández of AC Milan celebrates after scoring his team's third goal during the Serie A match between Udinese and AC Milan at Stadio Friuli on April 11, 2025 in Udine, Italy. (Photo by Alessandro Sabattini/Getty Images)

Theo Hernandez will not join Milan pre-season while waiting for Al-Hilal

Sunday’s reports confirm that Theo Hernandez will not join the rest of the Milan squad for the start of pre-season training next week while he awaits the formal completion of his transfer to Saudi Pro League side Al-Hilal. Theo Hernandez is on the verge of joining Al-Hilal on a permanent basis after six years in

Cornwall’s
United Kingdom

United Kingdom Unveils Stunning Coastal Escape as Cornwall’s Summerleaze Beach Becomes the Ultimate Staycation Hotspot for Sun-Seekers and Surf Lovers This Heatwave Season

Home » United Kingdom Travel News » United Kingdom Unveils Stunning Coastal Escape as Cornwall’s Summerleaze Beach Becomes the Ultimate Staycation Hotspot for Sun-Seekers and Surf Lovers This Heatwave Season Sunday, July 6, 2025 As temperatures soar across the United Kingdom this summer, Cornwall’s breathtaking Summerleaze Beach is capturing the attention of travelers seeking an

epa11606524 FC Inter's Davide Frattesi on the ground during the Italian Serie A soccer match between AC Monza and FC Inter, in Monza, Italy, 15 September 2024. EPA-EFE/ROBERTO BREGANI

Frattesi: Inter midfielder requires surgery after Club World Cup

Sunday’s reports confirm that Inter midfielder and Italy international Davide Frattesi is set for a brief spell on the sidelines, as he requires surgery to address a hernia problem that he has been suffering from over the last few weeks. Frattesi travelled with the rest of the Nerazzurri squad for their underwhelming FIFA Club World

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