严文彬

Results 148 comments of 严文彬

[demo](https://codepen.io/xboxyan/pen/bPoBKQ) ```css .btn { padding: .5em 1em; text-align: center; background: none; border: 1px solid; font-size:1rem; border-radius: 5em; color: #ef7077; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .btn-group{ display: flex; padding:...

```js //Element.matches if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector } //Element.closest if (!Element.prototype.closest) { Element.prototype.closest = function(selector) { var element = this; while...

```js //1. document.cookie //2 document.cookie = 'userid=1'; //3 document.cookie = 'userid=1;max-age='+60*60*24;//如果是本地时间可以直接用max-age document.cookie = 'userid=1;expires='+new Date(+new Date(time)+60*60*24).toUTCString(); //4 function getCookies(name){ var obj = {} document.cookie.replace(/\s?(\S+)=(\S+);/g,function($1,$2,$3){ obj[$2] = $3; }) return name?obj[name]||'':obj;...

```js document.addEventListener( "visibilitychange", function(){ if( !document.hidden ){ getAccount(); } }) ```

```js //1. var textarea = document.querySelector('textarea'); //2. textarea .rows = 5; //3. getComputedStyle( textarea ).height; //4. function setHeight( textarea ){ var styles = getComputedStyle(textarea); var lineHeight = getComputedStyle(textarea).lineHeight; if (...

[demo](https://codepen.io/xboxyan/pen/QWWEgVy) ```html Unwatch 63 Unstar 63 Fork 63 ``` ```css /* 按钮组小尺寸不换行没有支持 */ summary::-webkit-details-marker{ display: none; } details{ display: inline-block; } .ui-group{ font-size: 0; color: #24292e; line-height: 20px; } .ui-group+.ui-group{...

平时用的很少,一些符号和规则还不知道怎么匹配,求指点 ```js function charCheck(str){ var regs = [ { reg:/([\u4e00-\u9fa5]+[A-Za-z]+|[A-Za-z]+[\u4e00-\u9fa5]+)/g, txt:'中英文之间需要增加空格' }, { reg:/([\u4e00-\u9fa5]+\d+|\d+[\u4e00-\u9fa5]+)/g, txt:'中文与数字之间需要增加空格' }, { reg:/\d[A-Za-z]+/g, txt:'数字与单位之间需要增加空格' }, { reg:/([\s\S]{2}[\!|\·|\【|\】|\「|\」|\;|\:|\“|\”|\,|\《|\。|\》|\、|\?]\s+)|[\s+(\!|\·|\【|\】|\「|\」|\;|\:|\“|\”|\,|\《|\。|\》|\、|\?)[\s\S]{2}]/g, txt:'全角标点与其他字符之间不加空格' }, { reg:/(\~|\`|\!|\[|\]|\{|\}|\;|\:|\"|\'|\,|\|\/|\?|\!|\·|\【|\】\「\」|\;|\:|\“|\”|\,|\《|\。|\》|\、|\?)\1+/g, txt:'不重复使用标点符号' }, { reg:/(\S(——)|(——)\S)/g,...

借用一楼的`Throttle`节流函数。 ```js (function (doc, con) { var backTop = doc.getElementById('backTop'); var body = con || doc.documentElement; var setVisible = Throttle(function () { var h = body.clientHeight; var scrollTop = body.scrollTop;...

```js // 1 select.form; // 2 select.selectedIndex; // 3 select[2].value; // 4 const props = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value'); Object.defineProperty(HTMLSelectElement.prototype, 'value', { ...props, set(v) { props.set.call(this, v); this.dispatchEvent(new InputEvent('change')); } }) ```

[demo](https://codepen.io/xboxyan/pen/zYOmdyj) ```css .img{ width: 120px; height: 160px; } .tag{ box-sizing: border-box; position: absolute; text-align:center; font-size: 12px; color: #fff; min-width: 2em; min-height: 2em; padding: .3em .5em; } .tag[type="1"]{ background: #cd0000 }...