Skip to content

Instantly share code, notes, and snippets.

View jbrz0's full-sized avatar
🌟

Justin Brazeau jbrz0

🌟
View GitHub Profile
@jbrz0
jbrz0 / jquery-scroll.js
Last active December 11, 2017 11:40
Simple jQuery scroll function to scroll to an object and animate with time range
$('a[href^="#"]').on('click', function(event) {
var target = $( $(this).attr('href') );
if( target.length ) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, 6500);
}
});
@jbrz0
jbrz0 / jquery-random-colours.js
Created April 4, 2016 02:48
jQuery random colour div
// Requires jquery color
$(document).ready(function() {
spectrum();
function spectrum(){
var hue = 'rgb(' +
(Math.floor(Math.random() * 256)) +
',' + (Math.floor(Math.random() * 256))
+ ',' + (Math.floor(Math.random() * 256))
@jbrz0
jbrz0 / jquery-horizontal-bg.js
Created April 4, 2016 02:57
jQuery horizontal background w/ cursor
$(window).mousemove(function (e) {
var mousePosX = (e.pageX / $(window).width()) * 100;
var mousePosY = (e.pageY / $(window).height()) * 100;
// console.log(mousePosY)
$('.thumbs-block').css('backgroundPosition', mousePosX + '% ' + mousePosY +'%');
});
@jbrz0
jbrz0 / sass-mixin-breakpoints.scss
Last active April 18, 2020 03:26
Custom Sass mixin for using media queries
// Define the breakpoints
$breakpoint-small: 600px;
$breakpoint-med-small: 960px;
$breakpoint-med: 1175px;
@mixin screen($size, $type: max, $pixels: $breakpoint-small) {
@if $size == 'small' {
@media screen and ($type + -width: $breakpoint-small) {
@content;
}
@jbrz0
jbrz0 / sass-mixin-color-theme.scss
Created April 25, 2016 06:03
Define a multi-colored theme in your Sass stylesheet
//Create the mixin for theme colors
@mixin theme($name, $color) {
// Define colors in your theme
$primary: $color;
$secondary: lighten(adjust-hue($color, 20), 10%);
// Add your classes with css colors added
.#{$name} {
.element {
color: $primary;
}
@jbrz0
jbrz0 / sass-mixin-absolute-middle.scss
Last active August 20, 2020 08:50
Sass mixin for positioning an element absolute middle / centered vertical / centered horizontal
// Define vertical, horizontal, or both position
@mixin center($position) {
position: absolute;
@if $position == 'vertical' {
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@jbrz0
jbrz0 / sass-mixin-clearfix.scss
Created April 25, 2016 06:38
Sass mixin for quickly applying clearfix
// Clearfix mixin
%clearfix {
*zoom: 1;
&:before, &:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
@jbrz0
jbrz0 / sass-mixin-rem-font-size.scss
Created April 25, 2016 06:46
Sass mixin for setting default rem font sizes
// Define default font size
@function calculateRem($size) {
$remSize: $size / 16px;
@return $remSize * 1rem;
}
@mixin font-size($size) {
font-size: $size;
font-size: calculateRem($size);
}
@jbrz0
jbrz0 / sass-mixin-animations.scss
Last active April 17, 2020 18:14
Sass mixin to automate the CSS animation process, including vendor prefixes
//Animation mixin setup
@mixin keyframes($animation-name) {
@-webkit-keyframes #{$animation-name} {
@content;
}
@-moz-keyframes #{$animation-name} {
@content;
}
@-ms-keyframes #{$animation-name} {
@content;
@jbrz0
jbrz0 / sass-mixin-retina-image.scss
Last active April 17, 2020 18:14
Sass mixin for easy addition of retina images to CSS properties
@mixin image-2x($image, $width, $height) {
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
background-image: url($image);
background-size: $width $height;
}
}