Get a Free Quote

We respect your privacy

Advanced layout techniques for Responsive web design

9:44 am

Advanced layout techniques for Responsive web design

It is one thing to decide to go for a responsive web design and a completely other thing to actually successfully achieve that in reality. It is almost always the case that tools and method you start out with are not good enough to convert the entire website into a responsive one (if that is what you are doing). Same is the case when designing a responsive website from scratch. Thus, here we take a look at some advanced techniques and design elements that can help you create better responsive websites.

Touching the basics:

It is needless to say that a solid foundation builds a good site. The same applies to website design as well. It is only if you possess the basic knowledge of what responsive design really means that you will be able to work on the more advanced features. Responsive design is made up of the following three basic parts:

  • Flexible grids
  • Flexible media
  • Media queries that determine layout.

Besides being a cool technique; responsive web design is being termed as the best way to design a website by few. There are many things favoring it too. Like the web usage is trending towards mobile, even Google prefers sites to be responsive. In addition to which responsive redesigns lead to significant revenue and conversation ratings. It is simpler to manage the content on one site than two, three or may be more.

Layout Options:

Responsive web design Layout Options

There are many powerful tools that can be used to design your responsive website. Although, not every tool is right is every situation and hence it is important to know when and how to use each one of these methods. Doing this is a start and will greatly improve your website.

Floats:

Floats are a very handy tool in any form of design and they continue to be an easy and vital tool in responsive design as well. The basic benefits of using floats include:

  • They make line wrapping content much easier
  • Make the alignment of columns to the right or left an ease
  • Provide an ability to reverse the order of the floated items with float right or float left.
  • Are supported 100% on all browsers.
  • But don’t get carried away with floats; there are a few problems with floats as well:
  • Float elements do not honor relative height.
  • They require clearfix CSS to maintain content flow.
  • Considerable amount of CSS is usually required to adjust the alignment.

That said, in general floats are one of the simplest responsive layouts to implement. The advantage being that they have been around forever and everybody knows them. But there are situations that demand the use of other tools like when:

  • You require multiple columns with varied content to have the same box height.
  • Content needs to be vertically centered when it’s within a row.

Display Table Cell:

If in case you require to vertically align your content or even when every column in a row needs to be of the same height (which all of us can relate to , for example when you have a row of products to display) then this tools come is good use.

This table is very much a part of responsive design contrary to popular belief. CSS has the ability to make a set of elements a table using display:table and display:table-cell like mentioned here:

.parent { display:table }
.child { display:table-cell; vertical-align:middle;}
This is a quick and easy method to combat this alignment problem mentioned earlier. But it does come with its set of benefits and problems as well. The benefits being:

  • Every column of content has an identical height
  • Vertical-align: middle
  • fully supported on all modern browsers.
  • The problems with the same display:table-cell are as below though:
  • The cell widths are a suggestion and they expand to the width of the widest content.
  • You’re cannot line-wrap a cell

Text-Align:Justify:

There might not be many us who have not had to deal with issues related text alignment and times really complicated text alignment issues to do with videos, pictures and product description. The alignment is all doable though it takes a different technique that those already mentioned in this article.

It is possible to do something of the kind using the reference code provided below and it is supported in almost all the modern browsers as well.

.grid { text-align:justify;}
.grid-item {display:inline-block; width:22.5%; text-align:left;vertical-align:top;margin-bottom:3.33333%;}
.grid-item::after { content:”; display:inline-block;width:100%;}
.grid-item-extra { display:inline-block; border:0; margin:0;}
Again we check the benefits of doing so:

  • Eliminates the need to calculate margins between elements
  • Easy line-wrapping in long lists of elements
  • Easy alignment.
  • Supported in all modern browsers.
  • The problems being:
  • This technique requires extra markup.
  • Typographic issues arise from inline-block

Flexbox:

Flexbox is a really handy tool that gets you out of tough situations. The main benefits of using this tool are:

  • Once you actually fully understand it, CSS for Flexbox is easy to write.
  • As the name suggests it is truly flexible and can do almost anything.
  • You actually have true vertical and horizontal centering with Flexbox.
  • There are a few minor problems with this though:
  • You have to write three different syntaxes.
  • It has only partial support in Firefox.

Box-Sizing: Border-Box:

Using something like this mentioned below tells the browser to calculate an element’s width including its padding and border rather than just the content like is the default.

*,*::before, *::after { box-sizing:border-box;}

CSS3 Calc function:

Calculating values using the calc() function in CSS is a handy responsive trick. It is easy to simply design the layout with like width:70% and width:30%; but what happens when you require static width on a column. It is not possible to write something like width:70% and width:250px. And so then there is the calc() function. This CSS function has the ability to calculate a value using measurements with two different units. Take the following code as an example:

.content { width:calc(100%-200px); }
.sidebar {width:200px; }

Media Queries in JavaScript:

In the case that you require to trigger an event using the screen width and need it to happen at the same width as your breakpoint then the following will come in handy. $(window).width() or window.outerWidth. In the more modern browsers there is the option of using window.matchMedia() function. It does take one parameter though, a media query and returns a boolean indicating whether or not the media query is matched. As for the older browsers, Modernizr offers the .mq test that can be used in pretty much the same manner.

On conclusion:

Like everything else responsive design is evolving as well. You might have made your first responsive website way back in 2011. But the number tools available then were a lot less. Many new ideas and methods have surfaced since then; not to mention problems. But we always tend to find a solution to every problem hence you can definitely expect to see more tools and techniques as far as responsive web design is concerned.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...Loading...

Comments are closed.