Code Monkey home page Code Monkey logo

upperline-hs-responsive-web-design-stretch's Introduction

#Welcome to RWD!

By this point, as super-master-front-end wizards, you might be thinking, "But what if I want to see my beautiful page on my iPhone/Android/iPad/Kindle/Generic Mobile Device?" Well, now's your time. Welcome to the wonderful world of Responsive Web Design.

##What is RWD?

RWD, or Responsive Web Design is the practice of making your website or web app respond to different environments that it finds itself in, and adapt accordingly. So how do we achieve this? There are a few ways to do this, but the two main ways are through relative units and media queries.

###Relative Units In RWD, it is necessary to use relative units. In today's tech world, pixel sizes are getting smaller and smaller by the day. So, a border of 3px might look right on your screen, but on another monitor it might look too big or too small. So we want to use a unit called REMs for height, and percentage values for width.

####REMs REMs are a unit of height that are relative to your browser's default font size. Most browsers have a default font size of 16px. On those browsers, 1rem is equal to 1px.

####Percentages Percentages are a very useful unit of measurement, and should always be used for width. They do not work for height yet, but they are invaluable for RWD. Percentages are a bit finicky, because they have cascading properties. If you have an upper level div with width of 50%, it will take up 50% of the screen's width. However, if you put another div with width of 50% inside the outer div, the inner one will take up 50% of the outer div, but only 25% of the window.

###Media Queries A Media Query is a special kind of CSS selector. It contains styles that are only activated once certain conditions are met. The idea is to create styles that are only activated when the page has attributes that only happen when they are being displayed on a mobile device. So how do media queries work? Well, there are many kinds, but a very common one looks something like this:

@media screen and (max-width: 480px){
	//some CSS
}

But what exactly does that mean? Well, let's break it down.

@media is the prefix that lets the browser know "Hey, this is a media query."

screen is the first condition that we're setting. We're making sure that it is being displayed on a screen. Well, what's the point of this? Web pages can be displayed in may more ways that a screen, the best example being a printed page. So, if we wanted our page to look different when printed out, we could use a print condition.

and is just an operator that tells the browser that there's more on the way.

(max-width: 480px) is the real meat of the query. This is saying that these styles should only be activated when the browser window has a width of less than 480 pixels. Many smart phones have a screen width of around 480px, so 480 is a good ballpark guess for screen size.

Then, inside the {}, you put all of the CSS styles that should be applied. Use the normal syntax of CSS in the query's body.

###Multiple Media Queries If you want, you can have multiple queries in a single stylesheet, to cover landscape/portrait and tablets.

##Your Challenge Stored in this git repo is a bare-bones HTML page with some very basic styling. Your job is to add media queries so the all of the elements line up vertically on the page when displayed on an iPhone-sized window.

![Ref image] (res.png)

##Bonus Challenge Make the page look good.

View Welcome to RWD! on Learn.co and start learning to code for free.

upperline-hs-responsive-web-design-stretch's People

Contributors

dfenjves avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.