Last active
October 1, 2019 22:03
-
-
Save mishterk/301657a3293f4337fb9415b567a3643f to your computer and use it in GitHub Desktop.
A utility CSS class for removing margins on first and last child elements. For more info, see https://philkurth.com.au/tips/a-utility-css-class-for-removing-margins-on-first-and-last-child-elements/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.m-0-first-last > :first-child { | |
margin-top: 0; | |
} | |
.m-0-first-last > :last-child { | |
margin-bottom: 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define a mixin so we can use this anywhere we need it | |
@mixin first_last_marginless() { | |
> :first-child { | |
margin-top: 0; | |
} | |
> :last-child { | |
margin-bottom: 0; | |
} | |
} | |
// Set up a utility class using the mixin | |
.m-0-first-last { | |
@include first_last_marginless; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment