Skip to content
Home Blog Web Development Handy CSS Tips for Responsive Design

Handy CSS Tips for Responsive Design

  • Web Development
Blueprint Digital
Blueprint Digital

Insights from the Blueprint Digital team.

Responsive design seems to be everywhere these days. I previously shared some responsive design tricks as well as some other useful tips on responsive design. Today, I am going to offer some more CSS tips that will be especially handy for responsive web development.

CSS Media Queries for Retina Displays

Retina displays have a higher pixel ratio than regular screens. Therefore, images might not look too great on a mobile device. To deal with this problem, there are media queries for retina displays.

One of the joys of being a front-end web developer is dealing with browser compatibility issues. To deal with the different browsers available for the mobile platform, there are vendor prefixes for the retina display media query:

-webkit-min-device-pixel-ratio
min--moz-device-pixel-ratio
-o-min-device-pixel-ratio

In the actual CSS, the media queries will probably look something like this:

@media only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5),
only screen and (min-resolution: 144dpi) {
    .foo {
         background-image:url(images/bar.png);
     }
}

CSS Gradients

To provide a faster loading time on a mobile device and to avoid issues with different displays, it is probably better to use CSS3 gradients instead of making images out of gradients in Photoshop. However, the thing about CSS3 gradients is that the code can easily become too long if it is repeated. Therefore, it is useful to make one CSS class for a repeatedly-used gradient style. For example, you could have something like this:

.pink {
     background: #fcecfc;
     background: -moz-linear-gradient(top,  #fcecfc 0%, #ff7cd8 100%);
     background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#fcecfc), color-stop(100%,#ff7cd8));
     background: -webkit-linear-gradient(top,  #fcecfc 0%,#ff7cd8 100%);
     background: -o-linear-gradient(top,  #fcecfc 0%,#ff7cd8 100%);
     background: -ms-linear-gradient(top,  #fcecfc 0%,#ff7cd8 100%);
     background: linear-gradient(to bottom,  #fcecfc 0%,#ff7cd8 100%);
}

The CSS code above will generate something like this below, and you can use the .pink class everywhere you want the pink gradient to appear:

Using one class to apply to similar elements doesn’t only have to apply to gradients. This kind of solution seems simple, but when there are deadlines to meet, sometimes it can be hard to keep code clean and there may be duplicate code. Remembering that classes can be reused will be really handy.

Conclusion

I hope this article was helpful! What other CSS tips do you find useful? Leave a comment below.

Ready to Dominate Online and Grow Your Business?

Schedule time to connect with Blueprint about your online goals, or request a free review of marketing campaigns.

Related Posts

What Is Automated Lead Follow-Up and How Does It Work

What Is Automated Lead Follow-Up and How Does It Work

A new lead fills out a form, then waits. If the phone stays silent for a day, that lead has usually moved on to whoever answered first. Automated lead follow-up closes the gap. It is a marketing automation system that responds to every new inquiry within minutes, then continues the conversation through scheduled texts, emails,[...]
Free Advertising for Nonprofits Through Google Ad Grants

Free Advertising for Nonprofits Through Google Ad Grants

Advertising is usually the first line cut from a nonprofit budget, and the one that quietly costs the most to lose. Donors still search, scroll, and read, whether or not the cause has money to meet them there. Free advertising for nonprofits means promoting a cause without paying for placements, and it is how organizations[...]
Lead Scoring for B2B: How to Decide Which Leads Your Sales Team Chases

Lead Scoring for B2B: How to Decide Which Leads Your Sales Team Chases

Every marketing team has handed sales a list of leads that went nowhere. After a few of those lists, sales stops trusting them, works its own referrals instead, and the two teams settle into a standing argument about lead quality. Underneath the argument is a simpler problem: nobody has written down what a good lead[...]
Previous
Next

Partner with BLUEPRINT to reach your online goals, grow your business and reshape your story.

Get in touch with BLUEPRINT

Reach out to request a discovery call, a free campaign review, or for all other inquiries.

Subscribe to our newsletter