加入收藏 | 设为首页 | 会员中心 | 我要投稿 安阳站长网 (https://www.0372zz.cn/)- 高性能计算、分布式云、混合云存储、云计算、视频终端!
当前位置: 首页 > 运营中心 > 建站资源 > 优化 > 正文

JavaScript常用工具方法封装

发布时间:2019-02-15 09:49:36 所属栏目:优化 来源:佚名
导读:JavaScript 1. type 类型判断 isString(o){//是否字符串 returnObject.prototype.toString.call(o).slice(8,-1)==='String' } isNumber(o){//是否数字 returnObject.prototype.toString.call(o).slice(8,-1)==='Number' } isBoolean(o){//是否boolean retu

1. pc-reset PC样式初始化

  1. /* normalize.css */ 
  2.  
  3. html { 
  4.   line-height: 1.15; 
  5.   /* 1 */ 
  6.   -ms-text-size-adjust: 100%; 
  7.   /* 2 */ 
  8.   -webkit-text-size-adjust: 100%; 
  9.   /* 2 */ 
  10. } 
  11.  
  12. body { 
  13.   margin: 0; 
  14. } 
  15.  
  16. article, 
  17. aside, 
  18. footer, 
  19. header, 
  20. nav, 
  21. section { 
  22.   display: block; 
  23. } 
  24.  
  25. h1 { 
  26.   font-size: 2em; 
  27.   margin: 0.67em 0; 
  28. } 
  29.  
  30. figcaption, 
  31. figure, 
  32. main { 
  33.   /* 1 */ 
  34.   display: block; 
  35. } 
  36.  
  37. figure { 
  38.   margin: 1em 40px; 
  39. } 
  40.  
  41. hr { 
  42.   box-sizing: content-box; 
  43.   /* 1 */ 
  44.   height: 0; 
  45.   /* 1 */ 
  46.   overflow: visible; 
  47.   /* 2 */ 
  48. } 
  49.  
  50. pre { 
  51.   font-family: monospace, monospace; 
  52.   /* 1 */ 
  53.   font-size: 1em; 
  54.   /* 2 */ 
  55. } 
  56.  
  57. a { 
  58.   background-color: transparent; 
  59.   /* 1 */ 
  60.   -webkit-text-decoration-skip: objects; 
  61.   /* 2 */ 
  62. } 
  63.  
  64. abbr[title] { 
  65.   border-bottom: none; 
  66.   /* 1 */ 
  67.   text-decoration: underline; 
  68.   /* 2 */ 
  69.   text-decoration: underline dotted; 
  70.   /* 2 */ 
  71. } 
  72.  
  73. b, 
  74. strong { 
  75.   font-weight: inherit; 
  76. } 
  77.  
  78. b, 
  79. strong { 
  80.   font-weight: bolder; 
  81. } 
  82.  
  83. code, 
  84. kbd, 
  85. samp { 
  86.   font-family: monospace, monospace; 
  87.   /* 1 */ 
  88.   font-size: 1em; 
  89.   /* 2 */ 
  90. } 
  91.  
  92. dfn { 
  93.   font-style: italic; 
  94. } 
  95.  
  96. mark { 
  97.   background-color: #ff0; 
  98.   color: #000; 
  99. } 
  100.  
  101. small { 
  102.   font-size: 80%; 
  103. } 
  104.  
  105. sub, 
  106. sup { 
  107.   font-size: 75%; 
  108.   line-height: 0; 
  109.   position: relative; 
  110.   vertical-align: baseline; 
  111. } 
  112.  
  113. sub { 
  114.   bottom: -0.25em; 
  115. } 
  116.  
  117. sup { 
  118.   top: -0.5em; 
  119. } 
  120.  
  121. audio, 
  122. video { 
  123.   display: inline-block; 
  124. } 
  125.  
  126. audio:not([controls]) { 
  127.   display: none; 
  128.   height: 0; 
  129. } 
  130.  
  131. img { 
  132.   border-style: none; 
  133. } 
  134.  
  135. svg:not(:root) { 
  136.   overflow: hidden; 
  137. } 
  138.  
  139. button, 
  140. input, 
  141. optgroup, 
  142. select, 
  143. textarea { 
  144.   font-family: sans-serif; 
  145.   /* 1 */ 
  146.   font-size: 100%; 
  147.   /* 1 */ 
  148.   line-height: 1.15; 
  149.   /* 1 */ 
  150.   margin: 0; 
  151.   /* 2 */ 
  152. } 
  153.  
  154. button, 
  155. input { 
  156.   /* 1 */ 
  157.   overflow: visible; 
  158. } 
  159.  
  160. button, 
  161. select { 
  162.   /* 1 */ 
  163.   text-transform: none; 
  164. } 
  165.  
  166. button, 
  167. html [type="button"], 
  168.  
  169. /* 1 */ 
  170.  
  171. [type="reset"], 
  172. [type="submit"] { 
  173.   -webkit-appearance: button; 
  174.   /* 2 */ 
  175. } 
  176.  
  177. button::-moz-focus-inner, 
  178. [type="button"]::-moz-focus-inner, 
  179. [type="reset"]::-moz-focus-inner, 
  180. [type="submit"]::-moz-focus-inner { 
  181.   border-style: none; 
  182.   padding: 0; 
  183. } 
  184.  
  185. button:-moz-focusring, 
  186. [type="button"]:-moz-focusring, 
  187. [type="reset"]:-moz-focusring, 
  188. [type="submit"]:-moz-focusring { 
  189.   outline: 1px dotted ButtonText; 
  190. } 
  191.  
  192. fieldset { 
  193.   padding: 0.35em 0.75em 0.625em; 
  194. } 
  195.  
  196. legend { 
  197.   box-sizing: border-box; 
  198.   /* 1 */ 
  199.   color: inherit; 
  200.   /* 2 */ 
  201.   display: table; 
  202.   /* 1 */ 
  203.   max-width: 100%; 
  204.   /* 1 */ 
  205.   padding: 0; 
  206.   /* 3 */ 
  207.   white-space: normal; 
  208.   /* 1 */ 
  209. } 
  210.  
  211. progress { 
  212.   display: inline-block; 
  213.   /* 1 */ 
  214.   vertical-align: baseline; 
  215.   /* 2 */ 
  216. } 
  217.  
  218. textarea { 
  219.   overflow: auto; 
  220. } 
  221.  
  222. [type="checkbox"], 
  223. [type="radio"] { 
  224.   box-sizing: border-box; 
  225.   /* 1 */ 
  226.   padding: 0; 
  227.   /* 2 */ 
  228. } 
  229.  
  230. [type="number"]::-webkit-inner-spin-button, 
  231. [type="number"]::-webkit-outer-spin-button { 
  232.   height: auto; 
  233. } 
  234.  
  235. [type="search"] { 
  236.   -webkit-appearance: textfield; 
  237.   /* 1 */ 
  238.   outline-offset: -2px; 
  239.   /* 2 */ 
  240. } 
  241.  
  242. [type="search"]::-webkit-search-cancel-button, 
  243. [type="search"]::-webkit-search-decoration { 
  244.   -webkit-appearance: none; 
  245. } 
  246.  
  247.  ::-webkit-file-upload-button { 
  248.   -webkit-appearance: button; 
  249.   /* 1 */ 
  250.   font: inherit; 
  251.   /* 2 */ 
  252. } 
  253.  
  254. details, 
  255.  
  256. /* 1 */ 
  257.  
  258. menu { 
  259.   display: block; 
  260. } 
  261.  
  262. summary { 
  263.   display: list-item; 
  264. } 
  265.  
  266. canvas { 
  267.   display: inline-block; 
  268. } 
  269.  
  270. template { 
  271.   display: none; 
  272. } 
  273.  
  274. [hidden] { 
  275.   display: none; 
  276. } 
  277.  
  278. /* reset */ 
  279.  
  280. html, 
  281. body, 
  282. h1, 
  283. h2, 
  284. h3, 
  285. h4, 
  286. h5, 
  287. h6, 
  288. div, 
  289. dl, 
  290. dt, 
  291. dd, 
  292. ul, 
  293. ol, 
  294. li, 
  295. p, 
  296. blockquote, 
  297. pre, 
  298. hr, 
  299. figure, 
  300. table, 
  301. caption, 
  302. th, 
  303. td, 
  304. form, 
  305. fieldset, 
  306. legend, 
  307. input, 
  308. button, 
  309. textarea, 
  310. menu { 
  311.   margin: 0; 
  312.   padding: 0; 
  313.   box-sizing: border-box; 
  314. }  

(编辑:安阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读