Skip to content

Instantly share code, notes, and snippets.

View michaelwhyte's full-sized avatar

Michael Whyte michaelwhyte

View GitHub Profile
@michaelwhyte
michaelwhyte / full-bleed-in-fixed-width.css
Created February 14, 2018 04:17
Full bleed element inside a fix-width parent
/* This code from this CSS-Tricks article:
https://css-tricks.com/full-width-containers-limited-width-parents/
*/
.full-width {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
@michaelwhyte
michaelwhyte / keyboard-accessible-dropdown.js
Created February 8, 2018 19:03
Make dropdown navigation bar keyboard accessible
const $nav = $('nav');
// The following JS modified from
// JS found at this per: http://codepen.io/laviperchik/pen/dlcBt
$.fn.accessibleDropDown = function () {
var el = $(this);
/* Make dropdown menus keyboard accessible */
@michaelwhyte
michaelwhyte / box-sizing-reset.css
Created February 6, 2018 17:55
Box Sizing Reset
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
@michaelwhyte
michaelwhyte / isnumeric.js
Last active January 30, 2018 21:08
A function to determine if a value is a number even if the value is a string number
// Code from this stackoverflow question
// https://stackoverflow.com/questions/175739/is-there-a-built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
function isNumeric(num){
return !isNaN(num)
}
@michaelwhyte
michaelwhyte / frame-based-animation.scss
Created January 25, 2018 07:05 — forked from robweychert/frame-based-animation.md
A simple Sass function for frame-based CSS animation
// If you have experience with animation in other media, CSS
// animation’s percentage-based keyframe syntax can feel pretty
// alien, especially if you want to be very precise about timing.
// This Sass function lets you forget about percentages and
// express keyframes in terms of actual frames:
@function f($frame) {
@return percentage( $frame / $totalframes )
}
@michaelwhyte
michaelwhyte / sr-only-class.css
Last active November 20, 2018 20:20
Screen Reader Only Class from Bootstrap
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
@michaelwhyte
michaelwhyte / .gitignore
Last active November 12, 2024 22:54
Starter Git ignore file for basic web development...
# OS generated files #
######################
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
.img-02:-webkit-full-screen img {
display: block;
margin: 0; /* overide pre-existing margin styles */
}
.img-02:-moz-full-screen img {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
var img02 = document.querySelector('.img-02');
img01.addEventListener('click', function(){
if(fullscreenAvailable){
launchFullscreen(img01);
}else{
alert('Sorry, fullscreen not available...');
}
<div class="img-02">
<img src="birds-on-jericho-beach.jpg" width="320" height="320" alt="" />
</div>