Open evantianx opened 7 years ago
backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-repeat
指定当前元素背面朝向观察者时是否可见。元素背面总是透明的,当其朝向观察者时,显示正面的镜像。
由于2D变换无透视效果,故该属性对2D变换无效。
backface-visibility: visibility | hidden
CSS背景相关属性的简写
初始值:
background-image: none
background-position: 0% 0%
background-size: auto auto
background-repeat: repeat
background-origin: padding-box
background-clip: border-box
background-attachment: scroll
background-color: transparent
当指定background-image
时,backgeound-attachment
决定背景在视口中固定还是随包含它的区块滚动。
语法
/*随页面滚动而滚动,同时也会根据其被应用的元素来确定位置及调整大小*/
background-attachment: scroll;
/*在视口中固定,根据视口大小确定位置及大小,因此图片可能会显示不够完全*/
background-attachment: fixed;
background-attachment: local;
background-attachment: inherit;
定义该元素的背景图片及背景色 如何混合.
指定元素的背景延伸到何处。
/*默认值,背景延伸到边框外边缘*/
background-clip: border-box
/*背景延伸到边框内边缘*/
background-clip: padding-box
/*背景延伸到元素内容外边缘*/
background-clip: content-box
background-clip: inherit
元素背景色,属性值为颜色值或者关键字"transparent"
为元素设置一个或多个背景图像;在绘制时,以z方向堆叠方式进行。先指定的图像会在之后指定的图像上绘制。然后border在它们之上绘制,而background-color
会在他们之下绘制。
最佳实践: 给予元素背景图片的同时,也应当赋予其背景色。(在网络状态不好的情况下,用户会首先看到背景色,而不是白色)
控制背景绘制位置,默认值为padding-box
.background-attachment: fixed
时无效。
background-origin: border-box
background-origin: padding-box
background-origin: content-box
background-origin: inherit
那么
background-clip
和background-origin
区别在哪儿呢? 前者是用来控制显示的,而后者是用来控制绘制的。换句话说,前者即便控制了在边框外边缘显示,而后者没有指定绘制位置也不能显示;反过来,即便后者绘制位置从边框外边缘开始,前者设置为非边框外边缘显示,那么背景也不能从外边缘显示。
指定背景图片的初始位置,这个初始位置是相对于background-origin
的值来说的。默认值为0% 0%
background-position: top;
background-position: bottom;
background-position: left;
background-position: right;
background-position: center;
background-position: 25% 75%;
background-position: 0px 0px, center;
如果只有一个值被指定,则该值默认为水平方向值,而垂直方向会被设置为50%。
指定背景图片以平铺效果重复出现及重复方式。
/* 单值语法 */
background-repeat: repeat-x;
background-repeat: repeat-y;
background-repeat: repeat; /*默认值*/
background-repeat: space; /尽可能重复,图像之间留有均匀空白**/
background-repeat: round; /*会进行挤压*/
background-repeat: no-repeat;
/* 双值语法: 水平horizontal | 垂直vertical */
background-repeat: repeat space;
background-repeat: repeat repeat;
background-repeat: round space;
background-repeat: no-repeat round;
background-repeat: inherit;
A
:active ::after align-content align-items align-self animation animation-delay animation-direction aniamtion-duration animation-fill-mode animation-iteration-count animation-name aniamtion-play-state animation-timing-function attr()
:active
:active
伪类用来匹配用户激活元素。允许页面在浏览器检测到活动时给予反馈。通常用于指用户按下鼠标然后释放它之间的这段时间,也可以用来匹配Tab按键。经常被用于<a>
和<button>
元素。 遵循L-V-H-A的规则,即:link
-:visited
-:hover
-:active
。这样可以保证样式不被覆盖。<a>
的:active
,到了IE8+才支持除<a>
外其他元素的:active
。:after
::after
用来匹配所选元素的最后一个虚拟子元素。 通常用content
属性为其添加内容。默认情况下这个元素是内联元素。Tooltips 实现一个hover提示(
attr()
+::after
):after
写法,IE9+支持::after
写法;只有Chrome和Firefox支持其动画和transition。align-content
安排flex容器中多行内容的垂直方向摆放形式(前提是在垂直方向上有多余空间)。适用于父容器
语法
align-items
安排flex容器中单行内容的垂直方向摆放形式(前提是在垂直方向上有多余空间)。适用于父容器
align-self
分配flex容器中某个子项在垂直方向的位置,会覆盖父容器的
align-items
属性。若在垂直方向上某个margin被设置为auto,则该属性无效。适用于子容器。初始值:
animation-delay
设置延迟时间。 正值会使元素延迟执行动画;负值会使元素提前预演一段时间动画且立即从指定位置开始动画,如设置为-2s,则动画从2s处立即执行。
animation-direction
设置动画执行方向。
animation-duration
定义一个动画周期持续的时间 默认为0s。 必须带单位,否则无效。同样负值也无效。
animation-fill-mode
指定动画开始或者结束时保持何种状态
animation-iteration-count
定义动画的循环次数,值可以是正整数,也可以是小数,还可以是
infinity
(无限循环)animation-name
指明元素所应用的关键帧,关键帧命名由大小写不敏感的字母a-z,数字0-9,下划线_,斜杠/和横线-组成。第一个非横线字符必须是字母,数字不能在字母前面,不允许两个横线出现在开始位置。
animation-play-state
表明当前动画状态。可读可写。这意味着我们可以通过查询这个属性值来获取动画状态信息,也可以通过传值来控制动画的执行。 值为running或paused
animation-timing-function
定义CSS动画在每一动画周期中执行的节奏。
attr()
获取选择到的元素的某一HTML属性值,目前浏览器仅支持将其用于伪元素中的
content
,其属性值采用伪元素所依附的元素。