User:Wyn/Special Issue 26

From XPUB & Lens-Based wiki

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 slider input (-webkit-slider-thumb) to move the facial features. Also, add transform and translateY to achieve precise positioning of the thumbs. 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) position: fixed is similar to the facial feature (like eye-group and eyebrow-group) in the face container and makes different visual effect display: block is like the face outline - it always takes up the full width available, starting on a new line display: flex helps arrange eyes and eyebrows in pairs (but I didn't use it in the end) 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.