Code Monkey home page Code Monkey logo

week_02-day_03-responsive-design's Introduction

General Assembly Logo

Responsive Web Design

Objectives

By the end of this talk, developers should be able to:

  • Use % width for responsive web design
  • Write media queries for responsive web design
  • Describe mobile first development

images/1-objectives

images/2-responsive

images/3-responsive-1

images/4-viewport

images/5-viewport

images/6-viewport

images/7-media-queries

images/8-media-queries

images/9-media-queries

images/10-media-queries

images/11-media-queries

images/12-media-queries

images/13-mobile-first

images/14-mobile-first

images/15-mobile-first

What are the most common dimensions for a website design?

Why don't you tell me! http://screensiz.es

images/device_breakpoints

Unit Description Usage
px Referred to as absolute units because px (pixel) units will always be the same size regardless of any other related settings. Most frequently with font sizes, margins, padding, max- and min- properties.
em, rem Relative to the current element's font-size (em), or the root font-size (rem). When used to set the font-size of an element, em is relative to the element's inherited size. Most frequently with font sizes, margins, padding, widths or heights that may need to be changed but remain relative to other elements.
vh, vw Relative to the viewport width (vw), where one unit is equal to 1/100th of the viewport's current width, or the viewport height (vh), where one unit is equal to 1/100th of the viewport's current height. Most frequently with width and height of structural page elements. Commonly used in responsive design.
% Percentages are relative values. What the percentage is relative to, is determined by the property associated with the percentage value. Most often used with width. Can be helpful to approximate intrisic sizing.

Examples of non-responsive sites:

It is becoming harder and harder to find non-responsive websites. But here is an example of a non-responsive website for you to try out.

Examples of mobile specific sites:

One way to create optimal experiences for mobile users is a dedicated mobile site.

You know you're on one when you see m. in the url!

Compare https://m.xkcd.com with https://xkcd.com

Avoid these... please.

Examples of responsive sites:

What's the difference between these? Let's resize again. Interestingly, Boston Globe was the first example of a responsive website.

Instead of manually resizing the page, which can be a pain, we can use Google Chrome DevTools.

Chrome DevTools in Action:

  • Let's visit GA's homepage
  • Click on the device icon next to the magnifying glass
  • You can change the pixel width (displayed at the top) using the drag tool
  • You can select any device using the dropdown menu at the top

Make a responsive website - Codealong

Flexible Images

We need images that fit their containers. By default, images will try to take up as much space as it's initial dimensions. This can cause some pain when you size up and size down your picture, especially if you are trying to control the size of your elements via a parent div.

It turns max-width: 100% is the answer. Most of the time. For any media.

Even as our flexible container resizes, shrinking or enlarging our image, the image’s aspect ratio remains intact.

img,
embed,
object,
video {
  max-width: 100%;
  height: auto;
}

Additional Resources

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.