Handy CSS Tricks for Responsive Design

Magora's tips about resp design

Designing your website to be responsive may be simple enough, but maintaining all the elements to look aesthetically pleasing and well-balanced on every screen size is an art that requires in-depth knowledge of CSS. In this article, we reveal some useful CSS tips and provide you with coding samples that can help make your responsive website look perfect across all devices. Nothing too complicated - just simple CSS properties like min and max width, overflow, relative value, etc. However, these simple aspects can make all the difference when it comes to responsiveness.

 

Box-sizing

You may be surprised, but box-sizing is an essential property for responsive website development. If you use box-sizing on an element with a width set in percent, it will take padding into account, so you’ll no longer need to adjust the width. Needless to say, this trick works best for mobile websites and browsers with CSS3 support.

code-1

Responsive Video

This CSS trick makes video content expand fullwidth to the boundary. To make it happen, you need to place the embed video code into a <div> container and specify 50-60% padding bottom. Then set 100% width and 100% height with absolute position for other elements such as iframe and object embed. The result will be that the embedded elements will automatically expand fullwidth.

code-2

Overflow Properties

Overflow: hidden is a handy CSS property that is helpful in many cases in addition to responsive design. Instead of clearing divs, you can clear containers by simply setting the overflow value to hidden. This property may be used for both complex and simple apps, making them much cleaner and relieving the necessity of having extra clearing divs.

code-3

Min-width & Max-width

  • The max-width property enables you to set the maximum width of an element. The purpose of this property is to prevent the element from becoming larger than the boundary.

This example shows the container specified to display at 700px if possible without exceeding 80% of the boundary width:
code-4

In the case of images, you can make them automatically resize to maximum width by using the max-width:100% and height:auto values:

code-5

  • Min-width is the opposite of max-width. It determines the minimum width of an element. For instance, you can use the min-width property on the input text field to prevent the field from getting too small when scaled down. It is applied in exactly the same way as in the max-width examples.

Knowing such simple yet handy tricks easily enables you to take care of the responsiveness of your website even if you are not a CSS pro. If you feel that even this is too much to handle on your own, get in touch with our mobile app development company team and we will go all out to optimise your existing website for mobile devices or even create a brand new, responsive solution from scratch.

Tom Dicson
November 09, 2016
recent
Facebook Creates New Opportunities for Startups How to Save 50% of Your Budget for App Development
recommended
App Development Calculator A Guide for Businesses: How to Create Apps Infographics: Magora development process The Best Mobile Apps for Businesses App Development Post Launch Activity
categories
News Technologies Design Business Development
Logo Magora LTD
close
Get in touch