目录 https://github.com/wenzi0github/javascript-css-common
- CSS初始化样式reset.css
- 去除浮动clearfix
- js操作cookie
- css强制换行/自动换行/强制不换行
- table边界的样式
- div上下左右居中
- 图片上下左右居中
- js字符串翻转
- iPad页面适配框架
- google html5.js
- js产生随机数字
- table中的td对齐属性
- radio-checkbox-select
- requestAnimationFrame的兼容性处理
- 获取鼠标移动的方向
- 扩展String中的format
- html字段转换函数
- js产生随机字符串
- 检测浏览器是否支持fixed
- 解析url中的参数
- 图片懒加载
- jQuery回到顶部
- 图片hover放大
- 时间格式化
- Object.assign兼容
- 标题两边的小横杠
- 如何获取当前所在周的起始和结束的日期
1. CSS初始化样式reset.css
不同的浏览器对各个标签默认的样式是不一样的,而且有时候我们也不想使用浏览器给出的默认样式,我们就可以用reset.css去掉其默认样式
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td { margin:0; padding:0; }
body, button, input, select, textarea { font:12px/1.5 tahoma, arial, 5b8b4f53; }
h1, h2, h3, h4, h5, h6{ font-size:100%; }
address, cite, dfn, em, var { font-style:normal; }
code, kbd, pre, samp { font-family:couriernew, courier, monospace; }
small{ font-size:12px; }
ul, ol { list-style:none; }
a { text-decoration:none; }
a:hover { text-decoration:underline; }
sup { vertical-align:text-top; }
sub{ vertical-align:text-bottom; }
legend { color:#000; }
fieldset, img { border:0; }
button, input, select, textarea { font-size:100%; }
table { border-collapse:collapse; border-spacing:0; }
2. 去除浮动clearfix
通常我们在有浮动元素的情况下,会在同级目录下再创建一个<div style="clear:both;"></div>
;不过这样会增加很多无用的代码。此时我们用:after
这个伪元素来解决浮动的问题,如果当前层级有浮动元素,那么在其父级添加上clearfix类即可。
.clearfix:after {
content: "