Defining your widthandheight risks breaking your image aspect ratio if you change one of those dimensions in your CSS. See W4F for tips on how to fix this.
The width and height attributes only accept pixel units and are a plain numbner (use 400, not 400px).
2. Selective image loading with srcset and sizes
Terminology
Device-pixel ratio
Device-pixel ratio is the number of device pixels per CSS pixel. This ratio is determined by the pixel density of the device and the zoom level of the browser.
Learning Objectives
Discuss the criteria which selective image loading can operate under: viewport width and a display’s pixel density.
Define alternate large, medium or small versions of an image using the srcset attribute.
Discuss the sizes attribute and how it can be used to set specific image sizes at defined breakpoints.
Discuss the use of the image-set CSS function for background images.
Image decisions are based on the current viewport width. Images that are smaller that the viewport will often load with a larger size than is needed.
srcset describes the alternate image sizes available and makes decisions accordingly when displaying the image. It will make these decisions based on the viewport width and the pixel-ratio of the device.
The image-set() CSS function is a partially supported feature in most browsers and is mostly used to serve optimized image to high density displays.
For more control of your image size at particular screen widths, you can use the newer sizes attribute to add media query-style instructions.
Open lab-time
Checkbox hacking a menu with Ash and Tony!
Tony’s goals for Lab-Time
Build a whiteboard checkbox into the program website?
Understand the problem.
Plan it out.
Brute force solution.
Dailies
Submit today’s Codepen/repo/gist to the Dailies section (in Assessments) in Brightspace.