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 / SASS: Full screen width image inside container with limited width
Created October 19, 2016 09:34
SASS: Full screen width image inside container with limited width
.container {
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
.full-width {
width: 100vw;
position: relative;
left: 50%;
@ralexandr
ralexandr / SASS: Retina images
Created October 19, 2016 09:14
SASS: Retina images
/*--------------------------------
Retina images
example:
.element {
@include retina {
background-image: url(../img/background@2x.png);
}
}
*/
@ralexandr
ralexandr / SASS: Align vertical+horizontal
Created October 19, 2016 09:13
SASS: Align vertical+horizontal
@mixin align($vertical: true, $horizontal: false, $position: relative) {
@if $position {
position: $position;
}
@if $vertical {
top: 50%;
}
@if $horizontal {
left: 50%;
}
@ralexandr
ralexandr / SASS: Font antialias
Created October 19, 2016 09:12
SASS: Font antialias
@mixin antialias {
font-smoothing: antialiased;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@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;
}
@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: 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: 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: 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: 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; }
}