Hiding Elements

Homework

  1. Positioning
  2. CSS Animation
  3. Optional: CSS Variables

Morning reflection

Housekeeping

  • Open assets directory added to the Library.
  • Browser test:
  • Poll: What image editor do you use?

Hiding Elements

Learning Objectives

  1. 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 absolute positioning.
    • Overlap a larger element with Explicit Grid item placement.
  2. Explore CSS positioning.
    • position: relative
    • position: absolute
    • top/bottom/left/right
    • z-index and stacking order
  3. Explore CSS Transitions? Grid Overlap? Review?

Materials

Key Takeaways

  • top/bottom/left/right and z-index only work on positioned elements.
  • The direction of top/bottom/left/right reverses depending on relative vs absolute(?)
  • On absolutely positioned elements, top/bottom/left/right are relative to:
    • body, OR;
    • the closest parent with position: relative.
  • z-index defaults to 1 for positioned elements. So, 2 will send an element to the top of the stack.

Open lab-time

  1. Try using the Checkbox hack to hide and display a mobile menu using one of the methods above.

    Warning: The checkbox hack above only works when the menu is the next downstream sibling of the input element, in source order.

  2. Try adding a transition in the above Gist.

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.