Giter Club home page Giter Club logo

04-responsive-profile's Introduction

Setup

We want to put the final touches on our profile page now. If you haven't already, let's copy our previous profile into this challenge's folder and add a CSS file to it:

cp -r ../03-Finishing-profile-design/profile .

Background & Objectives

Make our page responsive with media queries

Your profile is complete, but what happens if you re-size your browser window and make it smaller? Your page is not yet responsive 😱.

If you want a responsive design, you can add media queries in your CSS. To use media queries, you must have this line in the <head> of your html 👇

<meta name="viewport" content="width=device-width, initial-scale=1">

This allows your page to detect the width of the device you are using.

Media queries work a bit like an if statement in ruby. Basically you can define CSS rules that will only apply if the window is smaller than a given width. For instance, if you want a responsive container, you can build it like this:

@media (max-width: 960px) {
  /* For a screen < 960px, this CSS will be read */
  .container {
    width: 700px;
  }
}
@media (max-width: 720px) {
  /* For a screen < 720px, this CSS will be read */
  .container {
    width: 500px;
  }
}
@media (max-width: 540px) {
  /* For a screen < 540px, this CSS will be read */
  .container {
    width: 300px;
  }
}

Try to resize your window to understand how media queries work.

⚠️⚠️⚠️ Be careful with the order of your media queries ⚠️⚠️⚠️

As with if statements in ruby, order matters! If several conditions are true, the last CSS rule will be applied.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.