📎 Webclip
Eight CSS Tips for Advanced Layouts and Effects
The article collects eight CSS techniques for handling layout and visual effects with less reliance on extra scripting. It focuses on features such as sibling selectors, box-sizing: border-box, vertical padding for proportional height, font-size for proportional width, CSS tables, Flexbox, transforms, border-radius, and CSS filters.
Reading notes #
- Sibling selectors can replace some first/last-item logic and support patterns such as showing only active cards and the items after them.
- Setting
box-sizing: border-boxkeeps element sizing consistent across browsers. - Vertical padding can be used to give an element a height tied to its width, which also helps preserve video aspect ratios.
font-sizecan serve as the basis for width and height when an element’s dimensions are expressed inem.- Vertical centering of dynamic content can use
display: tableanddisplay: table-cell, or Flexbox when browser support allows it. - Same-height columns can be built with large negative
margin-bottomvalues and matchingpadding-bottom, with CSS tables and Flexbox as alternatives. transform: rotate(x)andborder-radiuscan turn boxy shapes into angled panes, circles, or ovals without altering the original content.- CSS filters, including
invertandhue-rotate, can create a night mode without a separate stylesheet.