CSS 基础-02
1.背景
属性名:background
子属性名:
background-color: 背景颜色
background-image: 背景图片 属性值:url(’ 链接地址 ‘)
background-repeat: 背景重复 属性值:no-repeat | repeat-x |repeat-y |repeat(默认)
position: X Y 若x和y的值为正数,向右或下移动;若x和y 的值为负数,向左或上移动
background-size: 背景大小
简写:background:[color | image | repeat | position[/size]]
注意:定位position尺寸必须放在size尺寸前面 10px 10px/200px
2.盒子阴影
属性名:box-shadow
属性值:s1,s2,s3,s4,s5(color),s6(insert)
- s1 水平位移 可负值
- s2 垂直位移 可负值
- s3 模糊度 不能取负值,0为不模糊
- s4 阴影面积 不能取负值,0为原大小,可以省略
- s5 阴影颜色
- 内阴影 后加inset,可省略
box-shadow: -104px -97px 0px 0px blue inset;
简写:box-shadow:s1 s2 s3 [s4] s5 [s6;]
拓展:
移动当前元素到页面中间
margin:100px auto;solid-实线 dashed-虚线 dotted-点状线 double-双实线
3.平滑过渡
属性名:transition
属性值:s1,s2,s3,s4
s1 过渡的标签名(transition-property)
取值:all(所有可以过渡的属性) none(不指定过渡的属性) <标签名>
s2 过渡的持续时间(transition-duration)
取值:<持续时间> 1 s = 1000 ms
s3 过渡速率(transition-timing-function)
取值:linear(线性) ease(平滑) ease[-in|-out](缓入、缓出、缓入缓出)
s4 延迟时间(transition-delay)
注意:transition能起作用的前提条件是该标签的属性值是可以进行 + / - 的值
eg:transition:a .5s ease / transition:all 1s ease ; / transition:p1,p2,p3 .5s ease
4.变形
属性名:transform
属性值:
- none 不变形
- rotate 旋转 单位:deg
- skew 扭曲 单位:deg
- skewX 指定水平方向扭曲
- skewY 指定垂直方向扭曲
- scale 中心缩放 单位:倍数
- scaleX 水平缩放 单位:倍数
- scaleY 垂直缩放 单位:倍数
- translate 位移 单位:px
- translateX 指定x轴方向的位移
- translateY 指定y轴方向的位移
注意:skew扭曲为90*奇数倍时,都会被扭曲成一条线,导致看不见
5.列表样式
属性名:list-style
属性值:
- list-style-image 项目列表标记图像
- none 不指定图像
- <url(‘ … ‘)> 使用指定图像作为项目列表标记
- list-style-position
- outside 标记放在文本外,且文本不依据标记对齐
- inside 标记放置在文本内部,依据标记对其文本
- list-style-type 项目列表标记类型
- disc 实心圆(默认)
- circle 空心圆
- square 实心方块
- none 不适用项目符号
简写:list-style[list-style-image]|[list-style-position]|[list-style-type]
6.溢出
属性名:overflow
包括overflow-x,和overflow-y
属性值:
- visible 不剪切(默认)
- hidden 将超出对象尺寸的内容进行裁剪,将不出现滚动条。
- auto 将超出部分内容剪切,并以滚动条方式显示超出对象
常见属性
width height
mingwidth maxheight
minheight maxheight
7.文本
text-indent: 首行缩进(也可控制图片)(单位:px ,%,em)
text-align: 水平对齐方式(left center right)(对image标签也起作用)
text-decoration 划线方式(underline overline line-through none blink)
text-shadow 文本阴影
格式:
text-shadow:h-shadow v-shadow blur color;text-overflow 溢出文本处理
- 属性值:clip 修建文本
- 属性值:ellipsis 使用省略号代替省略的文本ellipsis
强制转为一行:
white-space:nowrap;将溢出内容隐藏:
overflow:hiddenvertical-align 垂直对齐(top middle bottom)
(默认情况情况下,是对外垂直对齐)
(若对内对齐,则需要配合display属性)
将当前元素转为td单元
display:table cell垂直居中:
line-height:500px;vertical-align:middle;
8.鼠标样式
属性名:cursor(光标,指针)
属性值:
pointer 指向(手掌样式)
text 文本(大写的 i 字样式)
move 移动(十字箭头)
default 默认(鼠标指针)
none 隐藏箭头
补充:progress(正在进行)|wait(等待)|方向-size(双向箭头)|no-drop(无法拖动)|crosshair(十字准星)
9.字体图标
计算机中图片分为两类:位图、矢量图
位图:放大失真
矢量图:放大不失真
字体图标基本都是矢量图,可以使用字体的属性,但不能使用图片的属性
字体图标下载:阿里巴巴矢量图url(‘ https://www.iconfont.cn/ ’)
阿里字体图标使用:
1.下载图标文件
2.导入iconfont.css文件
3.给需要使用字体图标的标签赋予class=”iconfont”
4.给需要使用字体图标的位置填写相应的图标符号(查询demo_unicode.html文件)