How to make any css class mobile responsive like bootstrap

Jeremy Gottfried
Jeremy Gottfried’s tech blog

--

As a frontend developer who works mostly in ReactJS, I’ve become a huge fan of bootstrap responsive classes. Bootstrap minimizes the amount of custom css you need to write, and makes mobile-responsiveness as easy as adding a -lg-, -md-, -sm- , tag to a class name. Bootstrap’s syntax makes it easy to understand which screen sizes are affected by css media queries. Here are the actual media query sizes:

// Extra small devices (portrait phones, less than 576px)
// No media query for `xs` since this is the default in Bootstrap

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }

// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }

Bootstrap comes packed with a lot of helpful classes to control things like margin, width, flex-box grid, and padding. But it is missing some classes that I need as a developer. For example, every web app I’ve built required different font sizes on mobile. Bootstrap doesn’t have a responsive font size class. I’ve also noticed that bootstrap’s margin, padding, and size classes don’t always respond the way I expect. So I spent a few hours figuring out how to create my own…

--

--