markdown Snippets.md是我最常用的HTML,CSS和JavaScript代码片段,用于前端Web开发

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Snippets.md是我最常用的HTML,CSS和JavaScript代码片段,用于前端Web开发相关的知识,希望对你有一定的参考价值。

This is a collection of my most often used lines of code, as well as a few other examples I want to have ready at a moment's notice. These snippets focus on building HTML from scratch, linking in good web fonts, and setting up responsive styles for your pages.

# Table of Contents

- **[HTML Snippets](#html-snippets)**
- **[Font Snippets](#font-snippets)**
- **[CSS Snippets](#css-snippets)**
- **[JavaScript Functions](#javascript-functions)**
- **[Shell Commands](#shell-commands)**

# HTML Snippets

## Lorem Ipsum
#### Shortcut: `lorem`

```
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Donec fermentum augue sem. Sed eleifend, erat a venenatis euismod, felis arcu tempus quam, imperdiet vestibulum ipsum orci eget dui. Praesent semper commodo urna, vitae sodales tellus aliquet a. Suspendisse varius condimentum enim id ornare. Mauris porttitor interdum sem et convallis. Cras dictum, diam ut feugiat bibendum, tortor tellus aliquet massa, pulvinar posuere tortor enim vitae turpis. Sed ultrices augue turpis, et pellentesque est sagittis in. Aliquam ac quam nibh. Quisque et fringilla dolor. Nullam massa ipsum, semper convallis purus sit amet, mollis interdum leo. Vivamus ut tempor nunc.
Nunc finibus lacus eget orci pellentesque lacinia. Nullam vitae dui facilisis, venenatis velit vehicula, fringilla eros. Vestibulum interdum nulla eu nunc convallis rhoncus. Sed eget sapien magna. Nam quis finibus velit, eu dictum mauris. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam et libero quis velit consectetur lobortis. Donec a libero vel mauris faucibus porta.
Vestibulum malesuada pulvinar dolor vitae eleifend. Nunc maximus quam et tempus tempus. Cras tempus nibh quam, vitae sodales nisi egestas laoreet. Aenean sed tincidunt ex. Pellentesque blandit pharetra arcu, non volutpat nunc dapibus ut. Suspendisse convallis at nunc sit amet euismod. Suspendisse non sem elit. Ut pharetra enim in purus porttitor facilisis mollis ut nisl. Sed varius semper sollicitudin. Nullam aliquam sodales pulvinar. Nam tellus sapien, hendrerit ac mollis eget, rhoncus a diam.
Nunc eu lorem vitae nisl laoreet imperdiet. Etiam nunc velit, auctor ut felis id, vestibulum efficitur quam. Pellentesque commodo sit amet velit ut accumsan. Ut malesuada lacinia arcu, volutpat accumsan lorem rutrum ac. Integer tincidunt dui a neque accumsan, ut hendrerit leo cursus. Nulla sed mollis tortor, vitae luctus odio. Praesent gravida sed mauris ac laoreet. Pellentesque a lorem purus. Ut tincidunt ante ac nibh maximus, et suscipit risus sagittis. Nullam rhoncus augue eu semper ultrices. Quisque nec mollis ex. Suspendisse potenti.
```

## HTML Skeleton
#### Shortcut: `html`

```
<!DOCTYPE html>
<html>
<head>
  <meta charset=utf-8>
  <title></title>
  <style></style>
</head>
<body>
  <script></script>
</body>
</html>
```

## Mobile Meta Tags
#### Shortcut: `meta`

```
<meta name=apple-mobile-web-app-capable content=no>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<meta name=format-detection content="telephone=no">
<meta name=viewport content="width=device-width, initial-scale=1">
```

## Green Lock Favicon
#### Shortcut: `lock`

```
<link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABwElEQVR42pWST0sbURTFr7hzET+CmwouxA+gUvAPbbNTFIqCtH4D0Y2ubMAUIRlK0NZKiJjEjdqCKEZBFD+BQgJOdKAjCtKmghOVmlCa0znPOCbGEXzw49x377lnFm/k4TEMeRGLxRAIBODz+Yiq2Ts6knp56ui6NIRCIaRSKWQyGViWRVirHmf0uAaEw2FlNE2TXy6DvWQyCXpcA/x+PwzDUAvZrHhKZ+xxRo9rAE26roNaKEiVy+zpgHQ6DepzZvKvINUTG6K9j77BLV6qw2DMS5z7REK0gr3jBOT+Ss27eS8O8jvYz61hL7eK/bzSO9i3WbU926D3xt5xAq7z4hmYe43dPxEkroNYvwo6qlB3jT3lGYi8AnecgKu81PbPdmLL+ooV6+MtF35bFWW9rews6OVOaYCnb6YDifMpLP0aL/LBgffFn6pve6bR96W9IqD27ec2rJxpiJ+MKhZOxqhFnFp56K0I6A29xLI5iYgxXGSkoqYuH0+C3oqAnk+t2DyN4LsZxLcfAVfooZc7Za8wvCDRLq0ZXcFmdFM1ass9JfehuMTLXoFvenYpdca5NB7+lqbDjA31Eeih9+4/+A+4dfTbehtGHQAAAABJRU5ErkJggg==" rel="shortcut icon">
```

## Data Module
#### Shortcut: `data-module`

```
<section data-module>
</section>

<style>
  [data-module],
  [data-module]:before,
  [data-module]:after,
  [data-module] *,
  [data-module] *:before,
  [data-module] *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-kerning: auto;
    font-family: inherit;
    margin: 0;
    padding: 0;
  }
  [data-module],
  [data-module] * {
    line-height: 1;
    font-size: 10pt;
    font-family: 'Open Sans', 'Source Sans Pro', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
  }
</style>
```

## Basic HTML Page
#### Shortcut: `basichtml`

```
<!DOCTYPE html>
<html>
<head>
  <meta charset=utf-8>
  <meta name=viewport content="width=device-width, initial-scale=1">
  <title></title>
  <link href=http://fonts.googleapis.com/css?family=Fira+Sans:300,400,500,700,300italic,400italic,500italic,700italic rel=stylesheet>
  <link href=http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic rel=stylesheet>
  <link href=http://staticresource.com/basic.css rel=stylesheet>
  <style></style>
</head>
<body>
  <script></script>
  <!--[if lt IE 9]><script src=http://elementqueries.com/EQCSS-polyfills.js></script><![endif]-->
  <script src=http://elementqueries.com/EQCSS.js></script>
</body>
</html>
```

# FONT Snippets

## Wishlist (Open Sans)
#### Shortcut: `wishlist`

```
font-family: 'Open Sans', 'Source Sans Pro', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
```

## Wishlist (Source Sans)
#### Shortcut: `wishlist-alt`

```
font-family: 'Source Sans Pro', 'Open Sans', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
```

## Serif style
#### Shortcut: `serif`

```
font-family: 'PT Serif', Cambria, 'Hoefler Text', Utopia, 'Liberation Serif', 'Nimbus Roman No9 L Regular', Times, 'Times New Roman', serif;
```

## Source Code Pro style
#### Shortcut: `monospace`

```
font-family: 'Source Code Pro', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
```

## Source Sans link
#### Shortcut: `source-sans`

```
<link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic" rel=stylesheet type=text/css>
```

## Source Sans @import

```
@import url('//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,900,300italic,400italic,600italic,700italic,900italic');
```

## Open Sans link
#### Shortcut: `open-sans`

```
<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel=stylesheet type=text/css>
```

## Open Sans @import

```
@import url('//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,700,300,600,800,400');
```

## Fira Sans
#### Shortcut: `fira`

```
<link href="//fonts.googleapis.com/css?family=Fira+Sans:300,400,500,700,300italic,400italic,500italic,700italic" rel=stylesheet type=text/css>
```

## FontAwesome link
#### Shortcut: `fontawesome`

```
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel=stylesheet type=text/css>
```

## FontAwesome @import

```
@import url('//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css');
```

## FontAwesome style

```
font-family: 'FontAwesome';
```

## Ionicons link
#### Shortcut: `ionicons`

```
<link href="//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel=stylesheet type=text/css>
```

## Ionicons @import

```
@import url('//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css');
```

## Ionicons style

```
font-family: 'Ionicons';
```

## PT Serif link
#### Shortcut: `pt-serif`

```
<link href="//fonts.googleapis.com/css?family=PT+Serif:400,700,400italic,700italic" rel=stylesheet type=text/css>
```

## PT Serif @import

```
@import url('//fonts.googleapis.com/css?family=PT+Serif:400,700,400italic,700italic');
```

## Merriweather
#### Shortcut: `merriweather`

```
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic" rel=stylesheet type=text/css>
```

## Source Code Pro link
#### Shortcut: `source-code`

```
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro:300,400,500,600,700,900" rel=stylesheet type=text/css>
```

## Source Code Pro @import

```
@import url('//fonts.googleapis.com/css?family=Source+Code+Pro:300,400,500,600,700,900');
```

# CSS snippets

## Permissive Wildcard
#### Shortcut: `wildcard`

```
*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: auto;
}
```

## Preset
#### Shortcut: `preset`

```
*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: auto;
}
html {
  font-size: 10pt;
  line-height: 1.4;
  font-weight: 400;
  font-family: 'Open Sans', 'Source Sans Pro', Roboto, 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Myriad Pro', 'Segoe UI', Myriad, Helvetica, 'Lucida Grande', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, Geneva, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
}
q:before {content: '\201c'}
q:after  {content: '\201d'}
q q:before {content: '\2018'}
q q:after  {content: '\2019'}
```

## HTML Text Size
#### Shortcut: `text-size`

```
html {
  -webkit-text-size-adjust: 100%;
}
```

## Box Sizing
#### Shortcut: `box-sizing`

```
-webkit-box-sizing: border-box;
-moz-box-size: border-box;
box-sizing: border-box;
```

## Placeholder Style
#### Shortcut: `placeholder`

```
::-webkit-input-placeholder {
  color: rgba(0,0,0,.5);
}
:-moz-placeholder {
  color: rgba(0,0,0,.5);
}
::-moz-placeholder {
  color: rgba(0,0,0,.5);
}
:-ms-input-placeholder {
  color: rgba(0,0,0,.5);
}
::-ms-input-placeholder {
  color: rgba(0,0,0,.5);
}
:placeholder-shown {
  color: rgba(0,0,0,.5);
}
```

## MS Expand for Select Boxes
#### Shortcut: `expand`

```
select::-ms-expand {
  display: none;
}
```

## Image Floats
#### Shortcut: `float`

```
[class*="float-"] {
  display: block;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
  cursor: default;
  pointer-events: none;
}
@media (min-width: 500px) {
  .float-left {
    float: left;
    margin: 0 .5em .5em 0;
    max-width: 50%;
  }
  .float-right {
    float: right;
    margin: 0 0 .5em .5em;
    max-width: 50%;
  }
}
```

## Background Cover
#### Shortcut: `cover`

```
background: url('../img/bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
```

## Remove Tap Delay
#### Shortcut: `touch`

```
touch-action: manipulation;
```


## Tap Highlight
#### Shortcut: `highlight`

```
-webkit-tap-highlight-color: #f60 !important;
```

## User Select
#### Shortcut: `user-select`

```
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
cursor: default;
```

## Pretty Quotes

```
q:before   { content: '“'}
q:after    { content: '”'}
q q:before { content: '‘'}
q q:after  { content: '’'}
```

## Clear `:after`
#### Shortcut: `after`

```
*:after {
  content: '';
  display: block;
  clear: both;
}
```

## Firefox-only Styles

```
@-moz-document url-prefix() {
  div {
    color: red;
  }
}
```

## CSS Mobile Breakpoints
#### Shortcut: `breakpoints`

```
@media (min-width: 481px) {
}
@media (min-width: 769px) {
}
```

## EQCSS Mobile Breakpoints
#### Shortcut: `eqcss-breakpoints`

```
@element 'html' {
}
@element 'html' and (min-width: 481px) {
}
@element 'html' and (min-width: 769px) {
}
```


# JavaScript Functions

## Print Current Year
#### Shortcut: `date`

```
<script>document.write(new Date().getFullYear())</script>
```

## EQCSS Embed
#### Shortcut: `eqcss`

```
<!--[if lt IE 9]><script src=http://elementqueries.com/EQCSS-polyfills.js></script><![endif]-->
<script src=http://elementqueries.com/EQCSS.js></script>
```

## EQCSS Minified and Crunched
#### Shortcut: `eqcss-min`

```
/*EQCSSv1.1.0*/EQCSS={data:[],load:function(){for(var a=document.querySelectorAll("style"),c=0;c<a.length;c++)null===a[c].getAttribute("data-eqcss-read")&&(a[c].setAttribute("data-eqcss-read","true"),EQCSS.parse(a[c].innerHTML),EQCSS.apply());a=document.querySelectorAll("script");for(c=0;c<a.length;c++)null===a[c].getAttribute("data-eqcss-read")&&"text/eqcss"===a[c].getAttribute("type")&&(a[c].src?function(){var b=new XMLHttpRequest;b.open("GET",a[c].src,!0);b.send(null);b.onload=function(){EQCSS.parse(b.responseText);
EQCSS.apply()}}():(EQCSS.parse(a[c].innerHTML),EQCSS.apply()),a[c].setAttribute("data-eqcss-read","true"));a=document.querySelectorAll("link");for(c=0;c<a.length;c++)null===a[c].getAttribute("data-eqcss-read")&&"stylesheet"==a[c].getAttribute("rel")&&(a[c].href&&function(){var b=new XMLHttpRequest;b.open("GET",a[c].href,!0);b.send(null);b.onload=function(){EQCSS.parse(b.responseText);EQCSS.apply()}}(),a[c].setAttribute("data-eqcss-read","true"))},parse:function(a){a=a.replace(/\s+/g," ");a=a.replace(/\/\*[\w\W]*?\*\//g,
"");a=a.replace(/@element/g,"\n@element");a=a.replace(/(@element.*?\{([^}]*?\{[^}]*?\}[^}]*?)*\}).*/g,"$1");a.replace(/(@element.*(?!@element))/g,function(a,b){dataEntry={};b.replace(/@element ?["']([^"']*)["']/g,function(a,b){dataEntry.g=b});dataEntry.a=[];b.replace(/and ?\( ?([^:]*) ?: ?([^)]*) ?\)/g,function(a,b,c){a=null;a=c.replace(/^\d+(\D+)$/,"$1");a==c&&(a=null);c=c.replace(/^(\d+)\D+$/,"$1");dataEntry.a.push({measure:b,value:c,b:a})});b.replace(/{(.*)}/g,function(a,b){dataEntry.style=b});
EQCSS.data.push(dataEntry)})},apply:function(){var a,c,b,f,m,l,n,d,e,h,k;for(a=0;a<EQCSS.data.length;a++)for(f=document.querySelectorAll(EQCSS.data[a].g),c=0;c<f.length;c++){m="data-eqcss-"+a+"-"+c;f[c].setAttribute(m,"");n="data-eqcss-"+a+"-"+c+"-parent";f[c]!=document.documentElement&&f[c].parentNode.setAttribute(n,"");element_guid_prev="data-eqcss-"+a+"-"+c+"-prev";f[c].previousElementSibling&&f[c].previousElementSibling.setAttribute(element_guid_prev,"");element_guid_next="data-eqcss-"+a+"-"+
c+"-next";f[c].nextElementSibling&&f[c].nextElementSibling.setAttribute(element_guid_next,"");l=document.querySelector("#"+m);l||(l=document.createElement("STYLE"),l.id=m,l.setAttribute("data-eqcss-read","true"),document.querySelector("head").appendChild(l));l=document.querySelector("#"+m);h=!0;b=0;a:for(;b<EQCSS.data[a].a.length;b++){e=window.getComputedStyle(f[c],null);k=null;f[c]!=document.documentElement&&(k=window.getComputedStyle(f[c].parentNode,null));d=!1;if("vw"===EQCSS.data[a].a[b].b){d=
!0;var g=parseInt(EQCSS.data[a].a[b].value);EQCSS.data[a].a[b].c=g*window.innerWidth/100}else if("vh"===EQCSS.data[a].a[b].b)d=!0,g=parseInt(EQCSS.data[a].a[b].value),EQCSS.data[a].a[b].c=g*window.innerHeight/100;else if("vmin"===EQCSS.data[a].a[b].b)d=!0,g=parseInt(EQCSS.data[a].a[b].value),EQCSS.data[a].a[b].c=g*Math.min(window.innerWidth,window.innerHeight)/100;else if("vmax"===EQCSS.data[a].a[b].b)d=!0,g=parseInt(EQCSS.data[a].a[b].value),EQCSS.data[a].a[b].c=g*Math.max(window.innerWidth,window.innerHeight)/
100;else if(null!=EQCSS.data[a].a[b].b&&"px"!=EQCSS.data[a].a[b].b&&"%"!=EQCSS.data[a].a[b].b){g=document.createElement("DIV");g.style.visibility="hidden";g.style.border="1px solid red";g.style.width=EQCSS.data[a].a[b].value+EQCSS.data[a].a[b].b;var p=f[c];f[c]!=document.documentElement&&(p=f[c].parentNode);p.appendChild(g);EQCSS.data[a].a[b].value=parseInt(window.getComputedStyle(g,null).getPropertyValue("width"));EQCSS.data[a].a[b].b="px";p.removeChild(g)}g=d?EQCSS.data[a].a[b].c:parseInt(EQCSS.data[a].a[b].value);
switch(EQCSS.data[a].a[b].measure){case "min-width":if(1==d||"px"==EQCSS.data[a].a[b].b)if(d=parseInt(e.getPropertyValue("width")),!(d>=g)){h=!1;break a}if("%"==EQCSS.data[a].a[b].b&&(d=parseInt(e.getPropertyValue("width")),e=parseInt(k.getPropertyValue("width")),!(e/d<=100/g))){h=!1;break a}break;case "max-width":if(1==d||"px"==EQCSS.data[a].a[b].b)if(d=parseInt(e.getPropertyValue("width")),!(d<=g)){h=!1;break a}if("%"==EQCSS.data[a].a[b].b&&(d=parseInt(e.getPropertyValue("width")),e=parseInt(k.getPropertyValue("width")),
!(e/d>=100/g))){h=!1;break a}break;case "min-height":if(1==d||"px"==EQCSS.data[a].a[b].b)if(d=parseInt(e.getPropertyValue("height")),!(d>=g)){h=!1;break a}if("%"==EQCSS.data[a].a[b].b&&(d=parseInt(e.getPropertyValue("height")),e=parseInt(k.getPropertyValue("height")),!(e/d<=100/g))){h=!1;break a}break;case "max-height":if(1==d||"px"==EQCSS.data[a].a[b].b)if(d=parseInt(e.getPropertyValue("height")),!(d<=g)){h=!1;break a}if("%"==EQCSS.data[a].a[b].b&&(d=parseInt(e.getPropertyValue("height")),e=parseInt(k.getPropertyValue("height")),
!(e/d>=100/g))){h=!1;break a}break;case "min-scroll-x":k=f[c].scrollLeft;if(1==d||"px"==EQCSS.data[a].a[b].b){if(!(k>=g)){h=!1;break a}}else if("%"==EQCSS.data[a].a[b].b&&(d=f[c].scrollWidth,e=f[c]==document.documentElement||f[c]==document.body?window.innerWidth:parseInt(e.getPropertyValue("width")),!(k/(d-e)*100>=g))){h=!1;break a}break;case "min-scroll-y":k=f[c].scrollTop;if(1==d||"px"==EQCSS.data[a].a[b].b){if(!(k>=g)){h=!1;break a}}else if("%"==EQCSS.data[a].a[b].b&&(d=f[c].scrollHeight,e=f[c]==
document.documentElement||f[c]==document.body?window.innerHeight:parseInt(e.getPropertyValue("height")),!(k/(d-e)*100>=g))){h=!1;break a}break;case "max-scroll-x":k=f[c].scrollLeft;if(1==d||"px"==EQCSS.data[a].a[b].b){if(!(k<=g)){h=!1;break a}}else if("%"==EQCSS.data[a].a[b].b&&(d=f[c].scrollWidth,e=f[c]==document.documentElement||f[c]==document.body?window.innerWidth:parseInt(e.getPropertyValue("width")),!(k/(d-e)*100<=g))){h=!1;break a}break;case "max-scroll-y":k=f[c].scrollTop;if(1==d||"px"==EQCSS.data[a].a[b].b){if(!(k<=
g)){h=!1;break a}}else if("%"==EQCSS.data[a].a[b].b&&(d=f[c].scrollHeight,e=f[c]==document.documentElement||f[c]==document.body?window.innerHeight:parseInt(e.getPropertyValue("height")),!(k/(d-e)*100<=g))){h=!1;break a}break;case "min-characters":if(f[c].value){if(!(f[c].value.length>=g)){h=!1;break a}}else if(!(f[c].textContent.length>=g)){h=!1;break a}break;case "max-characters":if(f[c].value){if(!(f[c].value.length<=g)){h=!1;break a}}else if(!(f[c].textContent.length<=g)){h=!1;break a}break;case "min-children":if(!(f[c].children.length>=
g)){h=!1;break a}break;case "max-children":if(!(f[c].children.length<=g)){h=!1;break a}break;case "min-lines":d=parseInt(e.getPropertyValue("height"))-parseInt(e.getPropertyValue("border-top-width"))-parseInt(e.getPropertyValue("border-bottom-width"))-parseInt(e.getPropertyValue("padding-top"))-parseInt(e.getPropertyValue("padding-bottom"));e=parseInt(e.getPropertyValue("line-height"));if(!(d/e>=g)){h=!1;break a}break;case "max-lines":if(d=parseInt(e.getPropertyValue("height"))-parseInt(e.getPropertyValue("border-top-width"))-
parseInt(e.getPropertyValue("border-bottom-width"))-parseInt(e.getPropertyValue("padding-top"))-parseInt(e.getPropertyValue("padding-bottom")),e=parseInt(e.getPropertyValue("line-height")),!(d/e+1<=g)){h=!1;break a}}}if(!0===h){b=EQCSS.data[a].style;b=b.replace(/eval\( *((".*?")|('.*?')) *\)/g,function(a,b){var e=f[c],d="";try{with(e)d=eval(b.slice(1,-1))}catch(g){d=""}return d});b=b.replace(/\$this/g,"["+m+"]");b=b.replace(/\$parent/g,"["+n+"]");b=b.replace(/\$prev/g,"["+element_guid_prev+"]");b=
b.replace(/\$next/g,"["+element_guid_next+"]");b=b.replace(/\$root/g,"html");try{l.innerHTML=b}catch(q){l.styleSheet.cssText=b}}else try{l.innerHTML=""}catch(q){l.styleSheet.cssText=""}}},f:function(a){function c(){try{n.doScroll("left")}catch(a){setTimeout(c,50);return}b("poll")}function b(c){if("readystatechange"!=c.type||"complete"==l.readyState)("load"==c.type?window:l)[h](k+c.type,b,!1),!f&&(f=!0)&&a.call(window,c.type||c)}var f=!1,m=!0,l=window.document,n=l.documentElement,d=!~navigator.userAgent.indexOf("MSIE 8"),
e=d?"addEventListener":"attachEvent",h=d?"removeEventListener":"detachEvent",k=d?"":"on";if("complete"==l.readyState)a.call(window,"lazy");else{if(!d&&n.doScroll){try{m=!window.frameElement}catch(g){}m&&c()}l[e](k+"DOMContentLoaded",b,!1);l[e](k+"readystatechange",b,!1);window[e](k+"load",b,!1)}}};EQCSS.f(function(){EQCSS.load();EQCSS.apply()});window.addEventListener("resize",function(){EQCSS.apply()});window.addEventListener("scroll",function(){EQCSS.apply()});
```

## Load EQCSS if it isnt loaded already

```
(function() {
  if (typeof EQCSS === 'undefined' && typeof EQCSS_loaded === 'undefined'){
    var elementQueries = document.createElement('script')
    elementQueries.src = 'http://elementqueries.com/EQCSS.js'
    document.body.appendChild(elementQueries)
    elementQueries.insertAdjacentHTML('beforebegin', '<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->')
    EQCSS_loaded = true
  }
})();
```

## Load EQCSS one-liner

```
if(typeof EQCSS==='undefined'&&typeof EQCSS_loaded==='undefined'){var eq=document.createElement('script');eq.src='http://elementqueries.com/EQCSS.js';document.body.appendChild(eq);eq.insertAdjacentHTML('beforebegin','<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->');EQCSS_loaded=true;};
```

## Empty EQCSS \<script\> tag

```
<script type="text/eqcss">
  @element 'html' {
  }
</script>
```

## Self-Executing JavaScript Widget (HTML + CSS)

```
(function() {
  var myWidget = document.createElement('section'),
      widgetStyles = document.createElement('style'),
      tag = document.querySelectorAll('[src*="myWidget"]')[0];
  myWidget.innerHTML = '\
    <!-- Add your HTML here, with line-breaks escaped by a "\" backslash character. -->\
    <!-- (Don\'t forget: you can escape any character, like quotes, as well -->\
    Hello\
  ';
  widgetStyles.innerHTML = '\
    /* Add your CSS here, with line-breaks escaped by a "\" backslash character */\
    html { background: #09f; }\
  ';
  function populateWidget(content) {
    tag.parentNode.insertBefore(content, tag.nextSibling);
  };
  populateWidget(widgetStyles);
  populateWidget(myWidget);
})();
```

## Self-Executing JavaScript Widget (HTML + EQCSS)

```
(function() {
  if (typeof EQCSS === 'undefined' && typeof EQCSS_loaded === 'undefined'){
    var elementQueries = document.createElement('script')
    elementQueries.src = 'http://elementqueries.com/EQCSS.js'
    document.body.appendChild(elementQueries)
    elementQueries.insertAdjacentHTML('beforebegin', '<!--[if lt IE 9]><script src="http://elementqueries.com/EQCSS-polyfills.js"></script><![endif]-->')
    EQCSS_loaded = true
  }
  var myWidget = document.createElement('section'),
      widgetStyles = document.createElement('style'),
      tag = document.querySelectorAll('[src*=\'myWidget\']')[0];
  myWidget.innerHTML = '\
    <!-- Add your HTML here, with line-breaks escaped by a "\" backslash character. -->\
    <!-- (Don\'t forget: you can escape any character, like quotes, as well -->\
    Hello\
  ';
  widgetStyles.innerHTML = '\
    /* Add your EQCSS here, with line-breaks escaped by a "\" backslash character */\
    @element "html" and (min-width: 0px) { html { background: #09f; } }\
  ';
  function populateWidget(content) {
    tag.parentNode.insertBefore(content, tag.nextSibling);
  };
  populateWidget(widgetStyles);
  populateWidget(myWidget);
})();
```

## Block Autofocus for Touchscreen (mobile) users

```
// Block autofocus for touchscreen users
onload = function(){
  if(('ontouchstart' in window)||(navigator.msMaxTouchPoints>0)){
    var field = document.querySelectorAll('[autofocus]');
    for(var i=0;i<field.length;i++) {
      field[i].blur();
    }
  }
}
```

## Sample Arrays of Data

```
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
```

```
var months = ['January','February','March','April','May','June','July','August','September','October','November','December']
```

```
var numerals = ['0','1','2','3','4','5','6','7','8','9']
```

```
var lowercase = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
```

```
var uppercase = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
```

```
var alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
```

```
var alphanumeric = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9']
```

```
var ascii = [' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_','`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~']
```

# Shell Commands

## Git Basics

```
git pull
git st
git add --all
git commit -m "" -m ""
git push
```

## Git Assume Unchanged
If you need to change a config file, _eg._ a `.htaccess` or `robots.txt` for a local environment but don't want to commit those changes to the repository, you can run this command _after_ your alteration has been made to ignore your alterations and assume that the state of your local repository is clean. This lets you track your config files within version control without including any secret information. You don't need to put config files in your `.gitignore` list.

```
git update-index --assume-unchanged filename.txt
```

## Display the status of local and remote git branches as a tree
#### Alias: `showtree`
[command breakdown](http://explainshell.com/explain?cmd=git+log+--all+--graph+--decorate+--oneline+--simplify-by-decoration)<br>
[screenshot](http://i.imgur.com/pWPEOoA.png)

```
git log --all --graph --decorate --oneline --simplify-by-decoration
```

## Display number of lines you have changed in the repository today
#### Alias: `lines`
[command breakdown](http://explainshell.com/explain?cmd=git+diff+--shortstat+%22%40%7B0+day+ago%7D%22)<br>
[screenshot](http://i.imgur.com/PNDfK6D.png)

```
git diff --shortstat "@{0 day ago}"
```

## Recursively search current directory for search term or regular expression
#### Alias: `findin`
[command breakdown](http://explainshell.com/explain?cmd=grep+-nr+%22%22)<br>
[screenshot](http://i.imgur.com/aSTvFcu.png)

```
grep -nr ""
```

## Display files and folders sorted by file size displayed in human-readable terms
#### Alias: `showdisk`
[command breakdown](http://explainshell.com/explain?cmd=du+-sh+*+%7C+sort+-hr)<br>
[screenshot](http://i.imgur.com/FJ2jXH0.png)

```
du -sh * | sort -hr
```

以上是关于markdown Snippets.md是我最常用的HTML,CSS和JavaScript代码片段,用于前端Web开发的主要内容,如果未能解决你的问题,请参考以下文章

简书的富文本编辑器和markdown编辑器功能比较

Markdown常用语法

Markdown常用基本语法

你是我最欣赏的人

大数据是我的工作,也是我最喜欢的技术

这几种 VSCode 扩展是我最喜欢的