Skip to content

Instantly share code, notes, and snippets.

@carlosascari
Last active November 22, 2017 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosascari/21b3179766014bae0c89ac068f6fdf9f to your computer and use it in GitHub Desktop.
Save carlosascari/21b3179766014bae0c89ac068f6fdf9f to your computer and use it in GitHub Desktop.
Custom css reset (in less) based on normalize.css
/**
* Copyright(c) 2017 Carlos Ascari Gutierrez Hermosillo.
* MIT License.
*/
// Based on normalize.css 7.0.0
// https://github.com/necolas/normalize.css/tree/7.0.0
// + This version allows removing IE support by version as well as
// as hiding rarely used tags.
// + Set @supportIE to `false` to disable IE support completely.
// + Set @minimumIE between (and including) `8` & `11` to set minimum IE
// version to support. @example: `9` will support version 9 and above.
@supportIE: true;
@minimumIE: 10;
html {
// Correct the line height in all browsers.
line-height: 1.2;
// Prevent adjustments of font size after orientation changes in
// IE on Windows Phone and in iOS.
text-size-adjust: 100%;
}
body {
// Remove default margin in all browsers
margin: 0;
}
article,
aside,
footer,
header,
nav,
section,
figcaption,
figure,
main {
// Add the correct display in IE 9-.
& when (@supportIE = true) and (@minimumIE <= 9) {
display: block;
}
}
h1 {
// Correct the font size and margin on `h1` elements within `section` and
// `article` contexts in Chrome, Firefox, and Safari.
font-size: 2em;
margin: 0.67em 0;
}
figure {
// Add the correct margin in IE 8.
& when (@supportIE = true) and (@minimumIE = 8) {
margin: 1em 40px;
}
}
hr {
// Add the correct box sizing in Firefox.
box-sizing: content-box;
height: 0;
// Show the overflow in Edge and IE.
& when (@supportIE = true) {
overflow: visible;
}
}
pre {
// Correct the inheritance and scaling of font size in all browsers.
font-family: monospace, monospace;
// Correct the odd `em` font sizing in all browsers.
font-size: 1em;
}
a {
// Remove the gray background on active links in IE 10.
& when (@supportIE = true) and (@minimumIE = 10) {
background-color: transparent;
}
// Remove gaps in links underline in iOS 8+ and Safari 8+.
-webkit-text-decoration-skip: objects;
}
abbr[title] {
// Remove the bottom border in Chrome 57- and Firefox 39-.
border-bottom: none;
// Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
text-decoration: underline;
text-decoration: underline dotted;
}
b,
strong {
// Prevent the duplicate application of `bolder` by the next rule in Safari 6.
font-weight: inherit;
}
b,
strong {
// Add the correct font weight in Chrome, Edge, and Safari.
font-weight: bolder;
}
code,
kbd,
samp {
// Correct the inheritance and scaling of font size in all browsers.
font-family: monospace, monospace;
// Correct the odd `em` font sizing in all browsers.
font-size: 1em;
}
dfn {
// Add the correct font style in Android 4.3-.
font-style: italic;
}
mark {
& when (@supportIE = true) and (@minimumIE <= 9) {
background-color: #ff0;
color: #000;
}
}
small {
// Add the correct font size in all browsers.
font-size: 80%;
}
sub,
sup {
// Prevent `sub` and `sup` elements from affecting the line height in
// all browsers.
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
audio,
video,
canvas {
// Add the correct display in IE 9-.
& when (@supportIE = true) and (@minimumIE <= 9) {
display: inline-block;
}
}
audio:not([controls]) {
// Add the correct display in iOS 4-7.
display: none;
height: 0;
}
img {
// Remove the border on images inside links in IE 10-.
& when (@supportIE = true) and (@minimumIE <= 10) {
border-style: none;
}
}
svg:not(:root) {
// Hide the overflow in IE.
& when (@supportIE = true) {
overflow: hidden;
}
}
button,
input,
optgroup,
select,
textarea {
// Change the font styles in all browsers (opinionated).
font-family: sans-serif;
font-size: 100%;
line-height: 1.15;
// Remove the margin in Firefox and Safari.
margin: 0;
}
button,
input {
// Show the overflow in IE.
& when (@supportIE = true) {
overflow: visible;
}
}
button,
select {
// Remove the inheritance of text transform in Edge, Firefox, and IE.
text-transform: none;
}
button,
html [type="button"], // <- Prevent a WebKit bug where (2) destroys native `audio` and `video` controls in Android 4.
[type="reset"],
[type="submit"] {
// Correct the inability to style clickable types in iOS and Safari.
-webkit-appearance: button;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
// Remove the inner border and padding in Firefox.
border-style: none;
padding: 0;
}
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
// Restore the focus styles unset by the previous rule.
outline: 1px dotted ButtonText;
}
fieldset {
// Correct the padding in Firefox.
padding: 0.35em 0.75em 0.625em;
}
legend {
// Correct the text wrapping in Edge and IE.
& when (@supportIE = true) {
box-sizing: border-box;
display: table;
max-width: 100%;
white-space: normal;
// Correct the color inheritance from `fieldset` elements in IE.
color: inherit;
}
// Remove the padding so developers are not caught out when they zero out
// `fieldset` elements in all browsers.
padding: 0;
}
progress {
// Add the correct display in IE 9-.
& when (@supportIE = true) and (@minimumIE <= 9) {
display: inline-block;
}
// Add the correct vertical alignment in Chrome, Firefox, and Opera.
vertical-align: baseline;
}
textarea {
// Remove the default vertical scrollbar in IE.
& when (@supportIE = true) {
overflow: auto;
}
}
[type="checkbox"],
[type="radio"] {
// Add the correct box sizing in IE 10-.
// Remove the padding in IE 10-.
& when (@supportIE = true) and (@minimumIE <= 10) {
box-sizing: border-box;
padding: 0;
}
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
// Correct the cursor style of increment and decrement buttons in Chrome.
height: auto;
}
[type="search"] {
// Correct the odd appearance in Chrome and Safari.
-webkit-appearance: textfield;
// Correct the outline style in Safari.
outline-offset: -2px;
}
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
// Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
-webkit-appearance: none;
}
::-webkit-file-upload-button {
// Correct the inability to style clickable types in iOS and Safari.
// Change font properties to `inherit` in Safari.
-webkit-appearance: button;
font: inherit;
}
details,
menu {
// Add the correct display in IE 9-.
// Add the correct display in Edge, IE, and Firefox.
display: block;
}
summary {
// Add the correct display in all browsers.
display: list-item;
}
template {
// Add the correct display in IE.
& when (@supportIE = true) {
display: none;
}
}
[hidden] {
// Add the correct display in IE 10-.
& when (@supportIE = true) and (@minimumIE <= 10) {
display: none;
}
}
// Enabled
a, b, body, br, button, footer, div, form, hr,
h1, h2, h3, h4, h5, h6, head, header,
html, i, iframe, img, input, label,
li, link, main, meta, nav, option, p,
svg, table, tbody, td, textarea, tfoot, th, thead
script, section, select, small, span, strong, style
title, tr, ul, video {}
// Disabled
abbr, address, area, article, aside, audio,
base, bdi, bdo, blockquote, canvas, caption, cite,
code, col, colgroup, data, datalist, dd, del, details,
dfn, dialog, dl, dt, em, embed, fieldset, figcaption,
figure, hgroup, ins, kbd, keygen, legend, map, mark, math,
menu, menuitem, meter, noscript, object, ol, optgroup,
output, param, picture, pre, progress, q, rb, rp,
rt, rtc, ruby, s, samp, slot, source, sub, summary, sup,
template, time, track, u, var, wbr { display: none; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment