Hiding Elements
Homework
- Positioning
- Read:: Absolute, Relative, Fixed Positioning: How Do They Differ? on CSS Tricks
- Read: position on MDN
- Read: Understanding CSS z-index on MDN
- CSS Animation
- Read: Using CSS transitions on MDN
- Read: CSS Transition Examples on Free Code Camp
- Reference:
transitionproperty - Optional: Using CSS animations
- Optional: CSS Variables
- Read: Using CSS custom properties (variables) on MDN
- Read: CSS Variables: Why Should You Care? on Google Developer
- Watch: Lea Verou on CSS Variable Secrets at SmashingConf Toronto 2018
Morning reflection
Housekeeping
- Open assets directory added to the Library.
- Browser test:
- Command Line Cheatsheet
- Do the Notice boxes display correctly?
- Command Line Cheatsheet
- Poll: What image editor do you use?
Hiding Elements
Learning Objectives
- Discuss the various methods for hiding an element.
- Set element to
display: none. - Set the element to
visibility: hidden. - Overlap a larger element using
z-index. - Move the element off the viewport with
absolutepositioning. - Overlap a larger element with Explicit Grid item placement.
- Set element to
- Explore CSS positioning.
position: relativeposition: absolutetop/bottom/left/rightz-indexand stacking order
- Explore CSS Transitions? Grid Overlap? Review?
Materials
- Tissue Contrast Illusion
relativeandabsolutepositioning.- Codepen: CSS Positioning
- Gist: CSS Positioning v0.1
- transitions
Key Takeaways
top/bottom/left/rightandz-indexonly work on positioned elements.- The direction of
top/bottom/left/rightreverses depending onrelativevsabsolute(?) - On absolutely positioned elements,
top/bottom/left/rightare relative to:body, OR;- the closest parent with
position: relative.
z-indexdefaults to1for positioned elements. So,2will send an element to the top of the stack.
Open lab-time
- Try using the Checkbox hack to hide and display a mobile menu using one of the methods above.
- Try one of the options listed in this Gist: Hiding an element
Warning: The checkbox hack above only works when the menu is the next downstream sibling of the
inputelement, in source order. - Try adding a
transitionin the above Gist.- For extra effect, try using the Cubic Bezier function as a timing function.
- See: Designing Meaningful Animation by Val Head
Tony’s goals for Lab-Time
- Work on lesson plans and homework for W4W-F and W5M-T.
Dailies
- Submit today’s Codepen/repo/gist to the Dailies section (in Assessments) in Brightspace.
