User:Wyn/Special Issue 26
Study CSS like a linguist
Introduction to the core function of the CSS
In the CSS workshop, We learned the CSS properties like linguists, we explored two fundamental concepts: display and position properties. The display determines how elements interact with each other on a page; The position defines how elements are placed within their container.
We could choose the display and position group, focusing on the fundamental properties that how they work in the webpage.
I learned that display determines how elements relate to each other in the document flow. The key values we covered were:
display: block |
---|
- Elements take up the full width available and start on a new line;
display: inline |
---|
- Elements only take up necessary space and flow within the text
display: inline-block |
---|
- A hybrid that allows width/height settings while flowing inline
display: none |
---|
- blank; Completely removes the element from view
The Position Property:
Position controls where elements are placed relative to other elements or the viewport. We explored:
position: relative |
---|
- Elements can be offset from their normal position
position: absolute |
---|
- Elements are positioned relative to their nearest positioned ancestor
position: fixed |
---|
- Elements are positioned relative to the viewport
CSS drawing
The face metaphor fits the functions of display and position. To understand concepts, I created an interactive face using HTML and CSS. This practice helped me visualize how display and position work together. The face became my canvas (like absolute positioning), with features like ears, eyes, and mouth representing different positioning scenarios. I used glide (-webkit-slider-thumb) to move the facial features. The combination of different display and position values creates complex layouts.
position: relative on the face container creates a positioning context for absolute-positioned elements (like the ears)
display: flex helps arrange facial features in an organized way
The face metaphor helped me remember that: The face itself (container) is like position: relative, providing a reference point Features like ears (position: absolute) need the face as their positioning context Eyes and eyebrows (display: flex) need to maintain their relationship with neighboring elements.