DEV Community

5 Useful Little CSS Tricks

Milecia on August 21, 2018

Every developer runs into some of those annoying little quirks in CSS. They can leave you scratching your head for days, wondering why you element ...
Collapse
 
markpinero profile image
Mark Pinero

You can also use flexbox on the parent element:

.nav {
  align-items: center;
  display: flex;
  height: x;
}

By altering line-height, you're only getting vertical alignment as a side-effect, so it may be better to apply it to the parent instead.

Collapse
 
baltz profile image
baltz

The preferred way to use 'line-height' is with integer, lika 'line-height: 1;'. This number multiplied by the element's font-size.

Collapse
 
philnash profile image
Phil Nash

This wouldn't have the effect of vertically centering the text in its parent though. This is a particular technique, otherwise I agree that using unit-less values is more useful.