fredwong-it
Published in

fredwong-it

Css — fit content within the page (min-width: fit-content)

I learnt something really cool today.

Problem

I tried to fix this ugly issue which the table content overflowed outside the page when I reduced the width of the screen.

It was pain in the ass and I tried all different way like position, display for the table and parent element but it still didn’t work.

Solution

I applied this to one of the parent element, and the issue would be fixed. Let’s see the difference.

min-width: fit-content;

before

after

Amazing.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store