Skip to content

Instantly share code, notes, and snippets.

View ralexandr's full-sized avatar
💭
You're never wrong to do the right thing

Alexander Radyushin ralexandr

💭
You're never wrong to do the right thing
View GitHub Profile
@ralexandr
ralexandr / gist:b36fda8c4df01db6564647907f26753e
Created October 19, 2016 08:50
SASS: To quickly centre a block element without having to worry about if there is any top or bottom margin already applied.
@mixin push--auto {
margin: {
left: auto;
right: auto;
}
}
@mixin pseudo($display: block, $pos: absolute, $content: ''){
content: $content;
display: $display;
position: $pos;
}
@ralexandr
ralexandr / SASS: Responsive ratio
Last active October 19, 2016 08:57
SASS: Responsive ratio
// use this for creating scalable elements (usually images / background images) that maintain a ratio.
// @include responsive-ratio(16,9);
@mixin responsive-ratio($x,$y, $pseudo: false) {
$padding: unquote( ( $y / $x ) * 100 + '%' );
@if $pseudo {
&:before {
@include pseudo($pos: relative);
width: 100%;
padding-top: $padding;
}
@ralexandr
ralexandr / SASS: triangles
Last active October 19, 2016 09:17
SASS: triangles
/*--------------------------------
CSS Triangle
used for creating CSS only triangles
example:
.element {
&::before {
@include css-triangle(blue, down);
}
}
*/
@ralexandr
ralexandr / SASS: Font Sans mixin
Created October 19, 2016 09:00
SASS: Font Sans mixin
@mixin font-source-sans($size: false, $colour: false, $weight: false, $lh: false) {
font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif;
@if $size { font-size: $size; }
@if $colour { color: $colour; }
@if $weight { font-weight: $weight; }
@if $lh { line-height: $lh; }
}
@ralexandr
ralexandr / SASS: Placeholder mixin
Last active October 19, 2016 09:15
SASS: Placeholder mixin
/*--------------------------------
Form input placeholder text
example:
input,
textarea {
@include input-placeholder {
color: $grey;
}
}
*/
@ralexandr
ralexandr / SASS: Media queries + breakpoints
Last active December 29, 2023 05:33
SASS: Media queries + breakpoints
// Usage:
// .site-header {
// padding: 2rem;
// font-size: 1.8rem;
// @include mq('tablet-wide') {
// padding-top: 4rem;
// font-size: 2.4rem;
// }
// }
@ralexandr
ralexandr / SASS: Z-Index mixin
Created October 19, 2016 09:07
SASS: Z-Index mixin
// Usage:
// .site-header {
// z-index: z('site-header');
// }
@function z($name) {
@if index($z-indexes, $name) {
@return (length($z-indexes) - index($z-indexes, $name)) + 1;
} @else {
@warn 'There is no item "#{$name}" in this list; choose one of: #{$z-indexes}';
@ralexandr
ralexandr / SASS: Init hardware acceleration
Created October 19, 2016 09:09
SASS: Init hardware acceleration
@mixin hardware($backface: true, $perspective: 1000) {
@if $backface {
backface-visibility: hidden;
}
perspective: $perspective;
}
@ralexandr
ralexandr / SASS: Truncate mixin
Created October 19, 2016 09:09
SASS: Truncate mixin
@mixin truncate($truncation-boundary) {
max-width: $truncation-boundary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}