严文彬

Results 148 comments of 严文彬

借助CSS动画来实时取值颜色 [demo](https://codepen.io/xboxyan/pen/xoqwRN) ```html ``` ```css .color{ color: red; background-color: blue; animation: color 1s linear forwards;/**控制动画时长和类型**/ } @keyframes color { to{ color: blue; background-color: red; } } ``` ```js var div...

```css #overlay:target{ display:block; } ``` 可以把HTML结构换一下,省去`js`操作 ```html 我是浮层 我是按钮 ```

```js const a = document.querySelectorAll('a'); const links = document.querySelectorAll('a[href],area[href]'); links.forEach(item=>{ const href = item.getAttribute('href'); if(href.startsWith('javascript:')){ item.setAttribute('role','button'); }else if(href.startsWith('#')||href.startsWith('/')){ //zxx: 题目没有要求根地址吧 item.setAttribute('rel', 'internal'); }else if(item.tagName=='A'&&item.host!==location.host){ item.setAttribute('target', '_blank'); item.setAttribute('rel', 'external nofollow noopener');...

```html ``` ```js class XImg extends HTMLImageElement { static get observedAttributes() {return ['width']; } constructor() { super(); } get width() { return this.getAttribute('width'); } connectedCallback() { this.render(); } render(){ this.style.width...

```js //zxx: .quiz-p的margin最好都重置下 ``` ### 方法1(IE8+) ```css .quiz { /* zxx: 这里要是去掉就好了 */ display:table; } .quiz-h { vertical-align:middle; padding:0 10px; } .quiz-p { display:table-cell; text-align:justify; padding-right:10px; } ``` ### 方法2(IE10+)...

[demo](https://codepen.io/xboxyan/pen/JzQoLo) ```html 提按生 9月30日 21:47 什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密 提按生 9月30日 21:47 什么秘密 提按生 9月30日 21:47 什么秘密 提按生 9月30日 21:47 什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密什么秘密 提按生 9月30日 21:47 什么秘密 ``` ```css html,body{ margin: 0; height: 100%; }...

1. 'styleSheets' 1. 'head' 'innerText' 1. nth-child 1. empty 1. 3 1. scope 1. ~ 1. not

```js // 第一题 function elsMid(str, len) { var t = len || 15; if (str.length > t) { var after = parseInt(t / 2) - 1; return str.slice(0, t -...

```js //zxx: 1,3测试不通过 function toCamelCase(str){ return str.replace(/\-([a-z])/g,function($1,$2){ return $2.toUpperCase(); }) } function toDashJoin(str){ return str.replace(/[A-Z]/g,function($1){ return '-'+$1.toLowerCase(); }) } function toCapitalize(str){ return str.toLowerCase().replace(/\b[a-z]/g,function($1){ return $1.toUpperCase(); }) } function toBetterUrl(str){ return...

[测试demo](https://codepen.io/xboxyan/pen/GRggwod) ```js //1. function toTrim(str){ return str.trim(); } //2. function toCDB(str){ return str.replace(/[\uff00-\uffff]/g,function($1){ return String.fromCharCode($1.charCodeAt(0)-65248); }) } //3. function removeCode(str){ return str.replace(/^\+86/g,''); } //4. function removeSpaceOrHyphen(str){ return str.replace(/[\s-]+/g,''); } //5....