The CSS Behind A Responsive Site

Published on
Modified on

It’s been impossible for a company to get by without a website for a very long time, now. Over the last couple of decades, this sort of platform has become more and more essential, becoming something which a lot of people use every day. Of course, though, a lot of web standards were made before phones ever existed. The appearance of so many different devices can make it hard to create a site which works on any screen. Thankfully, though, this post is here to help you, and it will be going through some of the CSS behind a responsive website.

The Very Basics: To begin, it’s time to think about the very basics, and especially the options you have which are already built for you. Many CMS systems, like WordPress, have loads of plugins available to make a website look great across devices. Along with this, you can also find loads of pre-built libraries with the tools you need to make your site responsive, and you just need to perform some searches to find them.

Using Your Units: Of course, though, in some cases, you might need to take a more direct approach with your responsive website. Thankfully, with the help of some measurement units, this should be nice and easy. Most notably, % and vh/vw are the most commonly used to make a site responsive.

.aClassName {
width: 50%;
height: 50%;

When using percentages, the element with the class on it will react based on it’s parent element. So, if it is sat inside a DIV tag which is 500px wide, “aClassName” would be 250px wide.

.anotherClassName {
width: 50vw;
height: 50vh;

Instead of using the parent element as a guide, an option like this is based on the size of the screen. In this case, our element would be 960px x 540px on a 1920px x 1080px screen.

Some Variable Rules: Along with being able to use units to achieve responsiveness, a lot of developers will use media rules to keep their site looking good. You can find an example of a rule like this below.

@media screen and (max-width: 480px) {
    .aClassName {
        width: 100vw;
        height: 100vh;

In this case, once the screen is smaller than 480px wide, it will change the element to be the full size of the screen, using view height and width to keep it responsive. This sort of rule is great as it is very lightweight and doesn’t require any additional scripts to get working.

Support Along The Way: For a lot of people, the idea of creating a fully-responsive website will be very daunting. Thankfully, though, there are loads of companies out there offering responsive web design services, making it nice and easy to get everything handled for you. Along with this, even having someone to test the site for you will help to make sure your efforts are worthwhile.

Hopefully, this post will inspire you to start working harder on the time you put into making your website look great on all devices. In a lot of cases, you will need loads of rules to do this, but it will be worth it once your site is done.

Leave a comment

No messages posted yet

Developer Poll


Add a comment

Send me your weekly newsletter filled with awesome ideas