- Quiz 8
Hold Down Ctrl+Shift+M (toggles device toolbar). Then from the drop-down menu select Edit/Add Custom Device.
- Defining the Viewport
His screen is 2560px wide. However, when he opens the viewport width it shows 1280px.
WHY? Because not all pixels are created equal.
- Pixels, pixels and more pixels!
Hardware Pixels vs. Device-Independent Pixels
DIP will always take the same amount of display on the screen regardless of the pixel density of the display. The 1280px DIPs scales up to 2560px HP. So you should always include the viewport meta tag in your pages.
- Pixelation
Mobile device pixels that found on the specs are the HP.
- Calculating DPR
With one DIP for every two hardware pixels, the device pixel ratio is 2.
- What's the difference?
The viewport and the device pixel ratio are both likely causes for the differences between devices.
- Calculating CSS pixels
Divide 1920px by 2 and you will get the answer. :)
- How wide is the viewport?
To solve the quiz divide the pixels by the DPR number.
- Setting the Viewport
initial-scale=1.0 means that the ratio between the DIP and CSS pixels is 1:1.
- Setting the Viewport
To pass the quiz add
<meta name="viewport" content="width=device-width, initial-scale=1.0">
to the header of the site.
- Large Fixed Width Elements
Using fixed width or absolute positions is not recommended. You should use relative positions.
- Max-width on elements
Setting a
max-width
of 100% should avoid overflow for most elements.
img, embed,
object, video {
max-width: 100%;
}
-
Relative Sizes
max-width
overrideswidth
so if you have them both then the max width will overrides the styles. -
Tap Target Sizes
Human fingers are at least 40 CSS pixels. So it is safer to give your buttons a Height and width of 48px.
- Tap Targets
min-width: 48px; min-height: 48px;
- Start Small
Starting small (eg. mobile first) might remove the need to re-design your website for larger screens.
- Project Part 1 Inspect Styles
The full answer of this quiz is in lesson
17
.
-
Lesson Intro
-
Basic Media Query Intro
Media queries are used to apply styles depending on device characterstics.
- Adding a basic media query
min-width:500px
means that the MQ will be triggered and styles applied only if the viewport is bigger than 500px.
- Next Step Media Queries
Developers usually use max-width and min-width media queries because they are relatively error-proof. Max-width styles get applied when the viewport is smaller than the specified width.
- Which styles are applied?
Remove what is there and change it with this code.
body {
background-color: green;
}
@media screen and (min-width: 600px) {
body {
background-color: blue;
}
}
@media screen and (max-width: 400px) {
body {
background-color: red;
}
}
- Breakpoints
Predefined widths at which majors layout changes happen. For example, swapping the main navigation for a burger one or other hidden version suitable for smaller screens.
- Breakpoints Pt. II
To see the screen resolution of the window you need to open DevTools. In that lessons you don't see the devtools open because he opened the DevTools in a separate window.
- Number of Breakpoints
2 for medium.com and 2 for the course example.
- Picking Breakpoints
Use your content as a guide to pick your breakpoints.
-
Picking Breakpoints 2
-
Pick a Breakpoint
-
Complex Media Queries
-
What Styles Are Applied? Guide
@media screen and ( max-width:400px)
@media screen and ( min-width:301px) and ( max-width:600px)
@media screen and ( min-width:601px)
@media screen and ( min-width:961px)
- Grids Helpful Guide
Bootstrap and 960
-
Flexbox Intro
-
Flex Item
Using the order you can change the order to whatever you want.
-
Deconstructing a Flexbox Layout
-
Deconstructing a Flexbox Layout
-
Deconstructing a Flexbox Layout(quiz)
Three columns width will be 33.33% because it will give you around 99.99%, almost 100%.
Walk through the most popular responsive layout patterns and learn the tools needed to implement them in your own designs.
- Intro to Patterns
There are 4 patterns: Mostly Fluid, Column Drop, Layout Shifter, Off Canvas
-
Pattern - Column Drop
-
Pattern - Mostly Fluid
-
Mostly Fluid Part 1(quiz)
-
Mostly Fluid Part 2(quiz)
The red is 33 and not 25.
-
Combining Fluid Layouts
-
Pattern - Layout Shifter
-
Which is Which?
-
Pattern - Off Canvas
-
Off Canvas Visualization
-
Project Part 2
Learn how to optimize images, tables, and fonts to make for the best responsive layouts.
1.Lesson Intro
- Images
You could have a high quality image as well as a smaller one.
- Tables
Hiddedn Colums / No More Tables / Contained Tables
- Responsive Tables - Hidden Columns
The drawback of this approach is that you hide content from the users.
- Hide Some Columns helpful link
@media screen and (max-width:499px){ .gametime { display:none } }
- Responsive Tables - No More Tables
9.Minor Breakpoints
Like changing the icons size or making the font a bit bigger.
10.Project.
Sam Dutton, the developer advocate at Google, explains the importance of getting responsive images right and helps you set up mobile developer tools.
-
Course Introduction
-
Why Responsive Images?
They shoud work no matter the screen size is.
-
Intro to Project
-
Setting up Your Environment
-
Setup for mobile Helpful Link
-
Using dev tools on mobile
-
Mobile tools for iOS Helpful Link
-
Lesson Wrap Up
Optimize images to display beautifully on all screen sizes. Learn about the difference between Raster vs Vector images, responsive CSS units, and setting up optimization tools.
- Sizing Intro
Make sure the recording icon is red. Then disable the cache. Then Hit F5.
To manipulate an element in the DOM. CLick on that element. (In your console) type $0. If the console is not showing below your element tab then go the horizontal three dots and click on show console drawer.
Edit DOM Firefox DOM_Property_Viewer Chrome DOM_Property_Viewer
In Chrome: You can see all the DOM Properties for a certain element by using console.dir($0)
// For checking the width of the img
$0.naturalwidth
-
Relative Sizing Calc
-
IMPORTANT! Udacity Front End Feedback Extension
-
calc()
Note: There MUST be a space on each side of the + and - operators. (A space is not required around * and / as the problem is an ambiguity around negation.) For example: calc(100px - 10%) will work. calc(100px-10%) will not.
margin-right: 10px;
width: calc((100% - 20px)/3);
/* This means that there is no margin right after the last img */
img:last-of-type{
margin-right: 0;
}
- Landscape and Portrait
Don't assume the view-port will always stay the same. The screen orientation can rotate and miss up your calculation
8.Less Well Known CSS Units
vh and vw. viewport height and viewport width. vmin and vmax
-
Raster and Vector vector-vs-raster-what-do-i-use
-
Rastor or Vector ?
Vector images can be scaled infinitely, which means that it'll be sharp and clear even on a 50m banner
- Raster and Vector Identification
SVG are vectors. JPG and PNG are Raster
- File formats
Use svg because it is really small and fast.
-
Spot the Differences
-
Spot the Differences 2
Compression ratio is different
-
Image Compression pagespeed
-
Project Part 1 imagemagick grunt-is-not-weird srcset-with-grunt grunt-responsive-images
- checkmark 'add to PATH'
- in gruntfile.js change the line 'engine:im' to 'engine:gm' which basically tells grunt to look for graphicsMagick(gm) instead of ImageMagick(im)
// Download imagemagick for your OS https://www.imagemagick.org/script/download.php
// Make sure you add it to the path variable
// cd to the project folder then type
npm install
npm install -g grunt
// inside the grunt file change the line 'engine:im' to 'engine:gm'
//Also add this code
width: 1600,
suffix: '_large_2x',
quality: 30
// ready!set!responsiveimages!
If the grunt tool didn't work for you. This website can be helpful (http://compressimage.toolur.com)
Dive deep into image alternatives like CSS and icon fonts and learn common strategies to alleviate latency.
-
Text Problems
-
CSS Techniques fast-loading
-
CSS background images
-
CSS background image techniques
cover vs contain
- Symbol characters
You might find your symbol as charaters which will inherit all the text properties.
-
Unicode Treble Clef Unicode Table
-
Icon Fonts zocial fontawesome weloveiconfonts CSS Tricks ARIA
-
Inlining images with SVG and data URIs
-
Strategy Quiz 1
-
Strategy Quiz 2
-
Strategy Quiz 3
-
Strategy Quiz 4
-
Project Part 2
Learn to use the srcset attribute and the picture element to choose images of the right size for your application for every viewing context.
- Responding to Screen Capability & View
Media queris will not help. There are other ways.
There are two flavors of srcset, one using x to differentiate between device pixel ratios (DPR), and the other using w to describe the image's width.
srcset-sizes high-dpi pixe density
- Sizes Attribute
In JavaScript you can get the source of an img element with currentSrc. The sizes attribute gives the browser information about the display size of an image element – it does not actually cause the image to be resized. That's done in CSS!
- Srcset
Set srcset equal to a comma separated string of filename multiplier pairs, where each multiplier must be an integer followed by an x. For example, 1x represents 1x displays and 2x represents displays with twice the pixel density, like Apple's Retina displays. The browser will download the image that best corresponds to its DPR . Also, note that there's a src attribute as a fallback.
Set srcset equal to a comma separated string of filename widthDescriptor pairs, where each widthDescriptor is measured in pixels and must be an integer followed by a w. Here, the widthDescriptor gives the natural width of each image file, which enables the browser to choose the most appropriate image to request, depending on viewport size and DPR. (Without the widthDescriptor, the browser cannot know the width of an image without downloading it!)
<img class="dpi" src="images/Den_Haag_2x.jpg" srcset="images/Den_Haag_2x.jpg 2x, images/Den_Haag_1x.jpg 1x" alt="Den Haag Skyline">
<img class="w" src="images/Australia_1280w.jpg" srcset="images/Australia_1280w.jpg 1280w, images/Australia_640w.jpg 640w" alt="Australia from Space">
- Scrset and Sizes
What if the image won't be displayed at the full viewport width? Then you need something more than srcset, which assumes the image will be full viewport width. Add a sizes attribute to the image with a media query and a vw value. srcset and sizes together tell the browser the natural width of the image, and how wide the image will be displayed relative to viewport width. Knowing the display width of the image and the widths of the image files available to it, the browser has the information it needs to download the image with the right resolution for its needs that is as small as possible. And it can make this choice early in the page load while the HTML is still being parsed.
<img src="images/great_pic_800.jpg"
sizes="(max-width: 400px) 100vw, (min-width: 401px) 50vw"
srcset="images/great_pic_400.jpg 400w, images/great_pic_800.jpg 800w"
alt="great picture">
<!-- Quiz Answer -->
<img class="w" src="images/Coffee_1280w.jpg" srcset="images/Coffee_1280w.jpg 1280w, images/Coffee_640w.jpg 640w" sizes="(max-width: 960px) 50vw, 100vw" alt="Coffee by Amy March from Turkey">
sizes consists of comma separated mediaQuery width pairs. sizes tells the browser early in the load process that the image will be displayed at some width when the mediaQuery is hit. In fact, if sizes is missing, the browser defaults sizes to 100vw, meaning that it expects the image will display at the full viewport width. sizes gives the browser one more piece of information to ensure that it downloads the right image file based on the eventual display width of the image. Just to be clear, it does not actually resize the image - that's what CSS does. In this example, the browser knows that the image will be full viewport width if the browser's viewport is 400px wide or less, and half viewport width if greater than 400px. It knows that it has two image options - one with a natural width of 400px and the other 800px.
-
The Full Monty Element/picture
-
Accessibility
General advice about alt attributes alt attributes should be descriptive for important images, like this body surfer. Because body surfing is important, I guess. alt attributes should be empty for images that are just decorations, like this boiler image. Do you get the joke? It's a boiler to represent boiler plate code, which is sometimes empty of content. alt attributes should be set on every image, just like this pig is set on being so darn cute.
-
Accessibility Promise
-
Project
allthepictures,allthetime
Explore the diversity of different users experience with websites and applications. Learn about using screen readers practically and recognize the challenge of building web experiences for all users.
- Introduction to Accessibility Google and Udacity course on Accessibility.
We often shorten the word "accessibility" to "a11y" because there's 11 letters between the "A" and "Y" in the word "Accessibility"
-
What is Accessibility
-
Understanding the diversity of users
Some statistics on disability for the US: Around 2% of the population has some kind of vision disability (i.e. are blind or have significant difficulty seeing even with glasses) Around 50% of the population has some kind of clinically significant refractive error (a visual impairment which may be corrected with glasses if mild enough) Around 8% of males and 0.5% of females have some form of color vision deficiency Around 2% of adults have a hearing disability Over 4% have a cognitive disability (difficulty remembering, concentrating, or making decisions)
- Diversity of Users (Broken Arm)
Correct! A broken arm would be a motor impairment that is temporary.
-
Diversity of Users (Blindness)
-
Diversity of Users (Audio)
-
Diversity of Users (Baby)
Holding a baby in one arm will definitely impact someone's motor abilities.
- Diversity of Users (Concussion)
A concussion can impair a person's visual and cognitive abilities. A concussion is a temporary impairment.
- Diversity of Users (RSI)
RSI can be a temporary or permanent impairment. RSI can be a temporary or permanent impairment.
-
Using a Screen Reader
-
Experiencing a screen reader
Koala
-
Checklists Web Content Accessibility Guidelines (WCAG) 2.0 WebAIM's
-
Using WebAIM Checklist
Operable 2.4.2
- Gear Shift into Course Practicalities
Manage focus - the location on a page that receives input from the keyboard. Discover how some users navigate website entirely with the keyboard, and how to optimize their experience.
-
Introduction to Focus
-
What is Focus?
TAB will move focus forward / SHIFT - TAB will move focus backwards / Arrow keys can be used to navigate inside of a component
-
Experiencing Focus
-
DOM Order Matters
-
Fixing DOM Order
-
Using tabindex tabindex
-
Deciding whats in focus
-
Which Elements Should Have Focus?
-
Managing Focus
-
Manage Focus Yourself
lesson2-focus/05-radio-group
- Offscreen Content
To find your missing focus you can type the following into your console: document.activeElement
- Implementing Offscreen Content
Changing the css for the specific class to display:none; will remove that element for the tab order.
- Modals and Keyboard Traps
Dive into the differences between visual UI and semantically designed accessible UI. Add semantic elements to HTML to create a user interface that works for everyone.
-
Semantics Introduction
-
Assistive Technology
-
Affordances
Are cues. Such as buttons and scroll bar. When you see a button you already know that you can click it. Even if nobody told you.
-
Experience Using a Screenreader
-
Experience a Screen Reader 2
-
The Accessibility Tree
- Matching simple DOM and A11y Tree
-
Semantics in Native HTML
-
Writing Semantic HTML Quiz
-
Writing Semantic HTML: The Name Game
-
Labeling Input Elements
Using the ChromeVox you could easily tell which element has a label because it is going to read it out loud.
- Text Alternatives
If you want to skip your image form being read by the screen reader, then you should give your image an empty alt text alt=""
- Labeling Images With ALT Text
Implement effective semantic navigation using headings, link text and landmarks.
-
Semantics - Navigating content - Intro
-
Navigating with a screen reader
-
Navigating by Headings
-
Using Headings
- Using Headings
-
Other navigational options
-
Other navigational options example
CTRL+Option+U to open Web Rotor
← and → to change panes within Web Rotor
Type search term with Web Rotor open to search within Web Rotor
Enter to move VoiceOver focus to item from Web Rotor
CTRL + Option + Spacebar to activate link/button/other element
CTRL + Option + ← ↑ ↓ → to explore content
CTRL + Option + CMD + H to move forward by heading
CTRL + Option + CMD + Shift + H to move backward by heading
CTRL + Option + W to have a word spelled out
-
Link Text
-
Link Text Quiz
-
Landmarks
-
Landmarks Quiz
Sometimes an HTML element may not have a role or value assigned semantically. In this lesson, you'll use ARIA attributes to provide context for screen readers.
-
Intro to Semantics: ARIA
-
Why ARIA
-
First Steps with ARIA
-
What can ARIA do for you?
-
Roleplaying
-
Custom radio button group with ARIA
- More Ways to Label
- Name That Element!
-
Breather
-
Default Semantics and Landmarks
-
ARIA Relationships
-
Combo Box
By using aria-setsize appropriately, we can tell assistive technology how many items are within an option or listitem element.
- Hidden In Plain Sight
- Name That Element Round 2
-
Recap so far
-
Introducing ARIA Live
-
Atomic Relevant Busy
-
Recap
-
Modal Dialog Quiz
Incorporate CSS styling into your accessible web design and use accessible colour schemes to improve accessibility.
-
Introduction to Style
-
Working with focus styles
Sometimes the default blue focus doesn't fit your desgin. For that you can use the Voice
- Write your own focus styles
- Input Modality
-
Styling with Aria
-
Quiz: Styling with ARIA
-
Responsive design for multi-device
-
Responsive design for multi-device Pt. 2
-
Mobile Screen Readers
-
Mobile Screen Readers iOS
It's called voice over. You might need to install the english language.It can be also called Voice Assistant
- Mobile Screen Readers Android
It's called Talkback
- Using Mobile Screen Readers
Kangaroo
-
Seque to Color & Contrast
-
Meeting Contrast Requirements
-
Contrast Audit
-
Don’t convey info with color alone
-
High Contrast Mode
In this real-world case study, given the front-end code for a static Restaurant Reviews App, revise the site to be responsive and achieve accessibility standards.