2 – Medias
A responsive layout is the first step to a fully responsive website. Now, let’s focus on a very important aspect of a modern website: medias, such as videos or images.
The CSS code below will ensure that your images will never be bigger than their parent container. It’s super simple and it works for most websites. Please note that the max-width
directive is not recognized by older browsers such as IE6. In order to work, this code snippet have to be inserted into your CSS stylesheet.
Although the technique above is efficient, sometimes you may need to have more control over images and display a different image according to the client display size.
As you can see, we used the data-*
attribute to store replacement images urls. Now, let’s use the full power of CSS3 to replace the default image by one of the specified replacement images if the min-device-width
condition is matched:
Impressive, isn’t it? Now let’s have a look to another very important media in today’s websites, videos.
As most websites are using videos from third parties sites such as YouTube or Vimeo, I decided to focus on the elastic video technique by
Nick La. This technique allows you to make embedded videos responsive.
The html:
And now, the CSS:
Once you applied this code to your website, embedded videos are now responsive.
3 – Typography
The last step of this tutorial is definitely important, but it is often neglected by developers when it comes to responsive websites: Typography.
Until now, most developers (including myself!) used pixels to define font sizes. While pixels are ok when your website has a fixed width, a responsive website should have a responsive font. Indeed, a responsive font size should be related to its parent container width, so it can adapt to the screen of the client.
The CSS3 specification included a new unit named rems
. They work almost identically to the em
unit, but are relative to the html
element, which make them a lot easier to use than ems
.
As rems
are relative to the html
element, don’t forget to reset html
font size:
Once done, you can define responsive font sizes as shown below:
Reference :--
Collected from different websites
#How to make your web page responsive
#Make your existing website responsive
#basics of making the web site responsive using css
#makeYourPageResponsive
Comments
Post a Comment