Syntax - Tasty Web Development Treats

CSS + JS Hacks We’re Fine With

Jan 17, 2022
This insightful discussion explores the quirks of CSS and JavaScript hacks that developers often shy away from. From the clever use of negative margins to unconventional centering techniques, the hosts dissect common misconceptions. They also dive into the intricacies of parseInt, function arguments, and the importance of button types. You'll learn why passing noopener to links is crucial for security. Overall, it’s a refreshing look at what’s considered acceptable in the evolving world of web development.
Ask episode
AI Snips
Chapters
Transcript
Episode notes
ADVICE

Negative Margins in CSS

  • Use negative margins in CSS to adjust document flow and create overlapping layered effects.
  • Unlike relative positioning or translation, negative margins affect subsequent elements.
ADVICE

parseInt() Radix

  • Consider omitting the radix argument in parseInt() for base 10 or base 16 (hex) conversions.
  • parseInt() intelligently detects the base based on prefixes like '0x', simplifying the code.
ADVICE

Centering with Position and Translate

  • Center position fixed or absolute elements by combining left: 50% and translate: -50% on the x-axis.
  • While alternative methods exist, this technique remains useful in situations with limited HTML control.
Get the Snipd Podcast app to discover more snips from this episode
Get the app