1.css3中background简写属性
在开发中背景属性 background 还是很常用的, background 有很多属性,如:background-color 背景颜色background-image 背景图像background-position 背景图像的位置background-size 背景图片的尺寸background-repeat 重复背景图像background-origin 定位区域background-clip 绘制区域background-attachment 是否固定或者跟随页面滚动。( scroll :默认值,随页面滚动;fixed 固定,不滚动;inherit继承。)
当然这些属性可以分开写,也可以连写(简写),规则(顺序)如下:
background:color img_url repeat attachment position / size
颜色 图片地址 重复 是否固定 位置 / 尺寸
- 示例:
 
background:#F00 url('img/images.png') no-repeat fixed center / cover
红色背景,不重复,固定背景,居中,短边填充。
图像位置和尺寸用 / 隔开,前面是 background-position ,后面是 background-size 。
其中 background-position 的写法注意:语义描述时是 top left ,数值描述时是 x-pos y-pos ,两种顺序相反。 background-size 的写法是:width height 。
这样分开写会更好理解一些:
示例:
background:#F00 url('img/images.png') no-repeat fixed top left / 100% auto
书写规则
background: [background-color][background-image][background-repeat][background-attachment][background-position] / [ background-size] [background-origin] [background-clip];
需要注意的是里面的
/,它和font以及border-radius里简写方式使用的/用法相似。/可以在支持这种写法的浏览器里在background-position后面接着写background-size。
除此之外,你也可以增加另外两个描述它的属性值: background-origin和 background-cli示例
.example {background: aquamarine //背景颜色url(img.png) // 图片路径no-repeat // 是否重复平铺scrollcenter center / 50%content-box content-box;}
2. 单行文字超出出现省略号
.ellipsis-line {border: 1px solid #f70505;padding: 8px;width: 400px;overflow: hidden;text-overflow: ellipsis; //文本溢出显示省略号white-space: nowrap; //文本不会换行}
3.文字超出自动换行
.text{text-align: justify;text-justify: newspaper;word-break: break-all;}
4. 多行文字超出出现省略号
仅限在webkit内核浏览器中使用
.multi-line {border: 1px solid #f70505;width: 400px;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 3;//自定义行数-webkit-box-orient: vertical;}
5.flex布局的属性
6.grid布局的属性
7.checkbox美化
8.滚动条美化
9.两个文字和四个文字对齐
.text2 {letter-spacing: 2em;margin-right: -2em;}

10.hover显示曲线

.test {text-decoration: none;}.test:hover {background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 4'%3E%3Cpath fill='none' stroke='%23ff3300' d='M0 3.5c5 0 5-3 10-3s5 3 10 3 5-3 10-3 5 3 10 3'/%3E%3C/svg%3E") repeat-x 0 100%;background-size: 20px auto;animation: waveMove 1s infinite linear;}@keyframes waveMove {from {background-position: 0 100%;}to {background-position: -20px 100%;}}
11.inset属性
.box{inset:0px}
12. 覆盖但不影响操作
pointer-events: none
