Skip to content

Instantly share code, notes, and snippets.

View kerryChen95's full-sized avatar

kerryChen95 kerryChen95

  • AutoX
  • Beijing, China
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@wintercn
wintercn / adhocSort.js
Created September 30, 2013 03:19
假期前小玩意,ad-hoc排序
function shuffle(array){
for(var i = array.length-1; i > 0; i--) {
var rnd = Math.floor(Math.random() * (i+1));
var tmp = array[i];
array[i] = array[rnd];
array[rnd] = tmp;
}
}
function isInOrder(array) {
for(var i = 0; i < array.length-1; i++)
[
{
name:"HTML5",
uri:"http://www.w3.org/TR/html5/single-page.html",
category:"markup"
},
{
name:"HTML 5.1",
uri:"http://www.w3.org/TR/html51/single-page.html",
category:"markup"
@dreamsky
dreamsky / magnifier.html
Created June 10, 2013 06:29
前端试题:图片放大镜
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Magnifier Demo</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
@dreamsky
dreamsky / callee.js
Last active February 12, 2020 10:08
优秀的 JavaScript 代码片段集合
//JavaScript callee 用法示例
function factorial(num) {
if (num <= 1) {
return 1;
} else {
return num * arguments.callee(num - 1);
}
}
@dreamsky
dreamsky / css3-font-animation
Created May 29, 2013 07:32
前端试题:CSS3 文字放大效果
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>前端试题:CSS3 文字放大效果</title>
</head>
<style>
a {
display: table-cell;
width: 220px;
@dreamsky
dreamsky / nine-grid.html
Created May 29, 2013 07:11
前端试题:CSS 九宫格效果
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nine Grid</title>
<style>
ul {
width: 165px;
padding: 30px;
}
@gonghao
gonghao / example.js
Created December 28, 2012 14:55
Empty an Array with JavaScript
myArray = []; // bad
myArray.length = 0; // good!
@kejun
kejun / dabblet.css
Created December 7, 2012 02:17
Untitled
.mod {
position: absolute;
width: 300px;
background: #eee;
border: 1px solid #eee;
padding: 0 50px;
-webkit-box-shadow: 0 0 4px 0 rgba(0,0,0,0.2);
-moz-box-shadow: 0 0 4px 0 rgba(0,0,0,0.2);
box-shadow: 0 0 4px 0 rgba(0,0,0,0.2);
top: 50%;
@sofish
sofish / x.html
Created December 6, 2012 16:17
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>css</title>
<style>
a{display:table-cell;background:green;vertical-align:bottom;padding-left:10px;padding-bottom:5px;height:130px;width:250px;}
a:hover{-moz-transition:all ease-in 1s;-webkit-transition:all ease-in 1s;transition:all ease-in 1s;background:#8fc;font-size:40px;}
</style>
</head>