Skip to content

Instantly share code, notes, and snippets.

View AllThingsSmitty's full-sized avatar

Matt Smith AllThingsSmitty

View GitHub Profile
@AllThingsSmitty
AllThingsSmitty / code-highlight.css
Created October 31, 2017 10:41
CSS for highlighting code
code,
pre {
background-color: rgba(0, 0, 0, 0.04);
border-radius: 3px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
padding: 3px;
}
code {
white-space: nowrap;
@AllThingsSmitty
AllThingsSmitty / css-reset.css
Created October 18, 2017 19:54
Snippet for CSS reset
*,
*:before,
*:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
@AllThingsSmitty
AllThingsSmitty / system-fonts.css
Created July 12, 2017 14:28
Snippet for system fonts
body {
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
"Helvetica Neue",
sans-serif;
@AllThingsSmitty
AllThingsSmitty / flexbox-center-container.css
Created July 7, 2017 14:49
Snippet for vertical-/horizontal-aligned container
html, body {
height: 100%;
margin: 0;
}
body {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
@AllThingsSmitty
AllThingsSmitty / gist.md
Created December 20, 2016 12:18
Example of how to embed a Gist on GitHub Pages using Jekyll.

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

@AllThingsSmitty
AllThingsSmitty / toggle.js
Created October 13, 2016 19:24
Toggle show/hide password
function togglePassword() {
let passwordInput = document.getElementById('txtPassword');
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
} else {
passwordInput.type = 'password';
}
}
(function () {
@AllThingsSmitty
AllThingsSmitty / disable-right-click.js
Created July 28, 2016 23:18
Disable right-click menu
// credit: Louis Lazaris
window.addEventListener('contextmenu', function (e) {
console.log('context menu disabled');
e.preventDefault();
}, false);
document.addEventListener('mouseup', function (e) {
if (e.button === 2) {
console.log('right-click enabled');
}
@AllThingsSmitty
AllThingsSmitty / flexible-type.css
Last active February 21, 2017 10:17
Use :root for flexible type
/* This has been added to CSS Protips https://github.com/AllThingsSmitty/css-protips */
/* The type font size in a responsive layout should be able to adjust with each viewport.
You can calculate the font size based on the viewport height and width using :root */
:root {
font-size: calc(1vw + 1vh + .5vmin);
}
/* Now you can utilize the root em unit based on the value calculated by :root */
body {
@AllThingsSmitty
AllThingsSmitty / font-awesome-loaded.js
Created April 24, 2016 13:38
Dynamically check if Font Awesome CDN loaded
function css(element, property) {
return window.getComputedStyle(element, null).getPropertyValue(property);
}
window.onload = function () {
var span = document.createElement('span');
span.className = 'fa';
span.style.display = 'none';
document.body.insertBefore(span, document.body.firstChild);
@AllThingsSmitty
AllThingsSmitty / responsive-images.htm
Last active April 11, 2016 18:35
Automatically art-directed responsive images
<!-- source article: http://cloudinary.com/blog/automatically_art_directed_responsive_images -->
<picture>
<!-- wide crop -->
<source
media="(min-width: 600px)"
srcset="http://res.cloudinary.com/eeeps/image/upload/c_fill,ar_2:1,g_face,f_auto,q_70,w_600/on_the_phone.jpg 600w,
http://res.cloudinary.com/eeeps/image/upload/c_fill,ar_2:1,g_face,f_auto,q_70,w_1200/on_the_phone.jpg 1200w"
sizes="100vw">