Skip to content

Instantly share code, notes, and snippets.

@dropways
Last active March 13, 2024 08:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dropways/3e7489bcc093528f6f1d0c091a219462 to your computer and use it in GitHub Desktop.
Save dropways/3e7489bcc093528f6f1d0c091a219462 to your computer and use it in GitHub Desktop.
Custom SCSS Media Queries

MIXIN: Custom SCSS Responsive Media Queries.

@author Ankit Hingarajiya (https://github.com/dropways)

Creates responsive media queries for different screen resolution.

CSS content goes inside {} brackets.

min-width or max-width mixin

@mixin breakpoint( $max_min , $point ) {
	@if $max_min==min{
		@media ( min-width: ($point + px) ) {
			@content;
		}
	} @if $max_min==max{
		@media ( max-width: ($point + px) ) {
			@content;
		}
	}
}

How to use min or max width

.menu-link{
	padding: 15px 45px;
	@include breakpoint( max , 767){
		padding: 10px 25px;
	}
	@include breakpoint( min , 1366){
		padding: 15px 35px;
	}
}

min-width & max-width mixin

@mixin breakpoint-between($lower, $upper) {
	@media (min-width: ($lower + px)) and (max-width: ($upper + px)) {
    	@content;
	}
}

How to use min-width & max-width

.menu-link{
	padding: 15px 45px;
	@include breakpoint-between( 768 , 1024){
		padding: 10px 25px;
	}
	@include breakpoint-between( 1025 , 1366){
		padding: 15px 35px;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment