Skip to content

Instantly share code, notes, and snippets.

@attitude
Created February 19, 2017 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attitude/0fd95ae7af26a38630cb5b56254e3a3e to your computer and use it in GitHub Desktop.
Save attitude/0fd95ae7af26a38630cb5b56254e3a3e to your computer and use it in GitHub Desktop.
LESS CSS mixin to remove extra optical space above and below the block of text caused by how the browser distributes the line height property.
.remove-extra-line-height(@line-height: 1, @m-height: 0.7, @coef: 0.5) {
line-height: 1em * @line-height;
&:before,
&:after {
content: "";
display: table;
}
&:before {
margin-bottom: ((1 - @m-height) * @coef + (@line-height - 1) / 2) * -1em;
}
&:after {
margin-top: ((1 - @m-height) * (1 - @coef) + (@line-height - 1) / 2) * -1em;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment