Giter VIP home page Giter VIP logo

responsive-media-v-000's Introduction

Responsive Media

Overview

In this lesson we will look at a strategy for making our media content reponsive.

Objectives

  1. Adjust media sizing to be responsive.

Adjusting Media For Responsive Layouts

<iframe width="640" height="480" src="//www.youtube.com/embed/iC2yQbR_qys?rel=0&modestbranding=1" frameborder="0" allowfullscreen></iframe>

Note: Slides for this lecture video are provided in the resources at the bottom of this lesson.

Be Like Water!

โ€œYou must be shapeless, formless, like water. When you pour water in a cup, it becomes the cup. When you pour water in a bottle, it becomes the bottle. When you pour water in a teapot, it becomes the teapot. Water can drip and it can crash. Become like water my friend.โ€ -Bruce Lee

Using percent (%) measurements on our media allows them to fluidly fill the size of their container. In most cases our media is contained within the columns and rows of our layouts.

img, form, input, table, video, audio, iframe {
  width: 100%;
  max-width: 100%;
}

Here we set our images, forms, inputs, tables, videos, audio elements, and i frames all to expand width: 100%; setting them to be as wide as the parent they are inside of. Then using max-width: 100%; prevents them from getting any larger than their parent. Using both these properties will insure that they scale fluidly in all browsers. Having them fill their columns allows us to write fewer media queries overall as they will squish and expand until we set a fixed size for their parent elements.

Summary

  • We can set our media to width: 100%; max-width: 100%; to give them flexible fluid widths that will expand to the size of their parent. This allows us to write fewer media queries as they will resize to accomodate the device automatically in most cases.

Resources

View Responsive Media on Learn.co and start learning to code for free.

responsive-media-v-000's People

Contributors

sarogers avatar jongrover avatar annjohn avatar pletcher avatar itsjustarepo avatar gj avatar

Watchers

James Cloos avatar

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.