-
Gridz on gridz on gridz, fam

-
-
-
Learning Objective: Understand how to apply CSS towards building web layouts that work in multiple screens.
-
Basics
-
Examples of responsive sites
-
Always place this in your HTML
<html>
<head>
...
<meta name="viewport" content="width=device-width, initial-scale=1.0;">
...
</head>
...
</html>
-
Mobile First VS. Desktop First
These two schemas are techniques for how we structure our css. Most important takeaway: almost always go with mobile first.
(Remember, CSS is cascading which means that we can write one set of styles and then reapply other styles on top of that.)
-
With mobile first, we create the mobile layout first, then add a media query for tablet (with tablet styles) and then add a media query for desktop (with desktop styles)
-
With desktop first, we create the desktop layout first (so styles for desktop), then add a media query for tablet, then mobile.
-
Here’s why: forces you to think about the stuff that’s really necessary for simplest version of your page and implement those
With mobile first, you simply add styles as needed as width increases (vs removing styles the other way around, which leads to writing more code)
-
Here are some examples of different media queries.
-
NOTE: you should NEVER design for device specificity. Read this.
/* Smartphones (portrait and landscape) -- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) -- */
@media only screen and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) -- */
@media only screen and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) -- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) -- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) -- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}
/**********
iPad 3
**********/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* Desktops and laptops -- */
@media only screen and (min-width : 1224px) {
/* Styles */
}
/* Large screens -- */
@media only screen and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 -- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* iPhone 5 -- */
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6 -- */
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6+ -- */
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S3 -- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S4 -- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
/* Samsung Galaxy S5 -- */
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
-
Add responsive styles such that the column “rows” collapse into stacked bars when page width is less than 550px.
-
-
-
-
Do not apply collapse style to nav
-
Do not apply collapse style to nav
-
Learning Objective: What are front-end frameworks and how do they allow us to create modern, professional looking websites?
-
Some quick facts:
-
Some quick facts:
-
Some quick facts:
-
Some quick facts:
-
Let’s get a simple site going that pulls in one of the following frameworks. Let’s then use the documentation to build out a simple UI element using that framework. Frameworks are basically CSS stylesheets that were developed by other people. They are built in such a way that you don’t have to spend time and energy building out commonly reusable components like buttons and input fields, etc
-
Let’s see if we can rebuild our layouts using a frontend framework. Create a new project and then using the documentation provided by your the Bootstrap frontend framework, rebuild the following layouts. NOTE: you will likely have to add some of your own CSS styles here as well to achieve the gray boxes and min-heights.
-
-
-
-
-
-
Learning Objective: How can we build a professional looking website with a frontend framework?
-
Let’s revisit our resume page. We will create a resume webpage using Semantic UI.
-
Open ended! Let’s have fun with this and use our exploration as an excuse to learn more about the modules offered by Semantic UI.
Don’t forget, hw is due on Tuesday March 27th, midnight.