CSS
1.字体换行
1 | word-break: break-all; //包括数字 |
2.下划线
1 | text-decoration: line-through; |
3.控制文字在一行并且出现… 一行变省略
1 | overflow: hidden; |
4.控制文字在多行显示并且出现… 多行变二条字体的省略
1 | display: -webkit-box; |
5.去除重复的线条
1 | .nolayer { |
6.不知道盒子的宽高怎么让他垂直居中
1 | 父元素{ |
7.清除浮动的要点:
1 | .outer {zoom:1;} /*==for IE6/7 Maxthon2==*/ |
8.垂直居中
1 | .center { |
9.去除input type=number的上下箭头样式
1 | /*在chrome下:*/ |
10.一个1920_900的大图,在1024_768的分辨率只能显示一部分,希望仍居中显示
1 | .bg{ |
11.剪裁图像:
1 | img{ |
12.实现div两端对齐
1 | div{ |
13.如何透过CSS控制文章内的标点符号位置
1 | .article{ |
14.滚动条样式修改
1 | *::-webkit-scrollbar-track //轨道部分; |
15.图片居中
1 | /*如果是正方形*/ |
16.网页在Safari快速滚动和回弹的原理: -webkit-overflow-scrolling : touch;的实现
现在很多for Mobile的HTML5网页内都有快速滚动和回弹的效果,看上去和原生app的效率都有得一拼。
http://blog.csdn.net/hursing/article/details/9186199
17.今天发现移动端点击事件无法生效,但是滑动可以
然后就查一些资料,得到了一些理论知识。最重要的一个就是事件流的概念,点击事件可以分解成多个事件。 在移动端,手指点击一个元素,会经过:touchstart –> touchmove -> touchend –》click。 事件流本身会持续进行下去的。
http://www.myexception.cn/web/1600832.html
18.网页宽高clientWidth clientHeight获得数值不对的问题
当网页内容撑不满一屏时,通过以下代码获得整个网页高度会有问题
document.body.clientHeight; document.body.clientWidth;
得到的宽高不对,可能是因为html与body标签缺一个样式:height:100%
1 | html{ |
19.手机浏览器上,给body增加overflow:hidden;width:100%;height:100% 无效的问题
1 | 1、body加position:fixed; |
20.css修改input、textarea标签placeholder属性默认文字颜色
1 | input::-webkit-input-placeholder { |
21.四周阴影
1 | -webkit-box-shadow: #c5c5c5 0px 0px 10px; |
22.一个base64图片的微信加载样式
1 | <div class="weui-loadmore"> |
23、去除table表格的间隙
1 | border-collapse: collapse; |
24、CSS3 filter(滤镜) 属性 修改所有图片的颜色为黑白 (100% 灰度):
1 | img { |
25、vertical-align: 属性值
1 | baseline 默认。元素放在父元素的基线上。 |
26、pointer-events: none;
1 | auto: |
27、怎麼让一个未知宽高元素变为正方形1
2
3
4
5
6
7
8
9
10
11父元素:{
width:x;
height:y;
position:relative;
}
子元素:{
position:absolute;
width:20%;
padding-top:20%;
border-radius:50%;
}
28、一个阴影效果 适用于图片底部需要放置内容的地方1
2background: linear-gradient(bottom, rgba(0,0,0,0.7), rgba(255,255,255,0));
background: -webkit-linear-gradient(bottom, rgba(0,0,0,0.7), rgba(255,255,255,0));
29、js获取上传图片真实的尺寸大小和存储大小1
2http://blog.csdn.net/u014236259/article/details/52885591
让图片按比例缩放
30、输入框类型1
2
3
4
5
6
7
8
9
10
11
12
13
14
15textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="datetime"]:focus,
input[type="datetime-local"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
input[type="time"]:focus,
input[type="week"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="color"]:focus,
31、div模拟input输入框 contenteditable=”true”1
2
3
4
5
6
7
8
9
10
11
12<!-- html -->
<div class="test" contenteditable="true" data-text="和主播一起聊天-.-"></div>
<!-- 模拟 placeholder -->
<style>
.test:before {
content: attr(data-text);
}
.input_mnzz:empty:before {
content: attr(data-text);
color: #bbb;
}
</style>