经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
css
来源:cnblogs  作者:rabbit_zero  时间:2018/12/6 10:06:08  对本文有异议
  1. --------------------属性选择器-------------------------
  2. /*1.E[attr]:查找指定的拥有attr属性的E标签。如查找拥有style属性的li标签*/
  3. li[style]{
  4. text-decoration: underline;
  5. }
  6. /*2.E[attr=value]:查找拥有指定的Attr属性并且属性值为value的E标签。如想查找拥有class属性并且值为Red的li标签 =是严格匹配*/
  7. li[class=red]{
  8. /*font-size: 30px;*/
  9. }
  10. /*3.E[attr*=value]:查找拥有指定的attr属性并且属性值中包含(可以在任意位置)value的E标签*/
  11. li[class*=red]{
  12. /*font-size: 30px;*/
  13. }
  14. /*4.E[attr^=value]:查找拥有指定的attr属性并且属性值以value开头的E标签*/
  15. li[class^=blue]{
  16. font-size: 30px;
  17. }
  18. /*5.E[attr$=value]:查找拥有指定的attr属性并且属性值以value开结束的E标签*/
  19. li[class$=blue]{
  20. /*font-size: 30px;*/
  21. }
  22. -------------兄弟选择器-----------------------
  23. .first{
  24. color: red;
  25. }
  26. /*兄弟伪类:
  27. +:获取当前元素的相邻的满足条件的元素
  28. ~:获取当前元素的满足条件的兄弟元素*/
  29. .class+标签 只会查找下面拥有class属性子元素的子元素
  30. .first + li{
  31. color: blue;
  32. }
  33.  
  34. /*下面样式查找添加了.first样式的元素的所有兄弟li元素 他只能查找下面的兄弟元素
  35. 1.必须是指定类型的元素*/
  36. .first ~ li{
  37. color: pink;
  38. }
  39. -----------伪类选择器--------------
  40. /* first 下面所有li进行选中 */
  41. /* .first ~ li{
  42. color:red;
  43. } */
  44. /* 只会查找current 下面的第一个元素 */
  45. /* .first + li{
  46. color: blue;
  47. } */
  48. /* 选择属于父元素的第一个子元素的每个 <p> 元素。
  49. li:first-child{
  50. color:red;
  51. } */
  52. /* 选择属于父元素的最后一个子元素的每个 <p> 元素。 */
  53. /* li:last-child{
  54. background-color: aqua;
  55. } */
  56. /* 选择属于其父元素的首个 <p> 元素的每个 <p> 元素。只找一个元素 */
  57. /* li:first-of-type{
  58. background-color: red;
  59. } */
  60. ---------------------------------
  61. /* 选择属于其父元素的最后 <p> 元素的每个 <p> 元素。
  62. li:last-of-type{
  63. background-color: red;
  64. } */
  65. /* 选择属于其父元素的第N个子元素的每个 <p> 元素。
  66. li:nth-child(5){
  67. background: red;
  68. } */
  69. /* 查找所有的偶数 选择属于其父元素的第N个子元素的每个 <p> 元素。*/
  70. /* li:nth-child(even){
  71. background-color: red;
  72. } */
  73. /* 查找所有的奇数 选择属于其父元素的第N个子元素的每个 <p> 元素。*/
  74. /* li:nth-child(odd){
  75. background-color: red;
  76. } */
  77. /* 选择属于其父元素第N个 <p> 元素的每个 <p> 元素。 */
  78. /* li:nth-of-type(2){
  79. background-color: red;
  80. } */
  81. /* 最后一个子元素开始计数。N=0
  82. li:nth-last-of-type(-n+5){
  83. background-color: red;
  84. } */
  85. /* 选择属于其父元素第N个 <li> 元素的每个 <p> 元素。从头开始找
  86. li:nth-of-type(-n+5){
  87. background-color: red;
  88. } */
  89. /* 选择没有子元素的每个 <p> 元素(包括文本节点)。包括空格 */
  90. /* li:empty{
  91. background-color: red;
  92. } */
  93. ------------------------------
  94. p::selection{
  95. color:red
  96. }
  97. 他只能设置样式显示,不能改变内容大小
  98. -------------
  99. 获取第一个字符元素
  100. p::first-letter{
  101. color: red;
  102. }
  103. ----------
  104. /*获取第一行内容:如果设置了::first-letter,那么无法同时设置它的样式*/
  105. /* p::first-line{
  106. color: red;
  107. } */
  108. ----------
  109. /*设置当前选中内容的样式,鼠标选中它只能设置显示的样式,而不能设置内容大小*/
  110. P::selection{
  111. background-color: red;
  112. }
  113.  
  114. /*通过opacity设置透明度:如果设置父容器,那么父容器中的所有子元素也会透明*/
  115. opacity: 0.1;
  116. ----------------------
  117. 内减盒子
  118. box-sizing: border-box;
  119. /*content-box:你设置的width属性值仅仅是内容的宽度,盒子的最终的宽高值在width的基础上再加上padding和border的宽度*/
  120. /*border-box:你设置的width属性值就是盒子的最终的宽度,包含了border和padding和内容。如果添加了padding和border,那么真正放置内容的区域会减小--但是它可以稳固页面的结构*/
  121. ------阴影---------------------------
  122. /*添加阴影 text-shadow:offsetX offsetY blur color*/
  123. 立体感:.dome5{
  124. text-shadow: -1px -1px 0 #eee,-2px -2px 0 #ddd,-3px -3px 0 #ccc,-4px -4px 0 #bbb,-5px -5px 0 #aaa;
  125. }
  126. <!--文本阴影:text-shadow:offsetX offsetY blur color-->
  127. <!--边框阴影:box-shadow:h v blur spread color inset
  128. h:水平方向的偏移值
  129. v:垂直方向的偏移值
  130. blur:模糊--可选,默认0
  131. spread:阴影的尺寸,扩展和收缩阴影的大小--可选 默认0
  132. color:颜色--可选,默认黑色
  133. inset:内阴影--可选,默认是外阴影-->
  134. ----------------------------------------------
  135. 线性渐变:
  136. /*linear-gradient(方向,开始颜色 位置,颜色2 位置,颜色3 位置...);*/
  137. /*方向:
  138. to top:0deg
  139. to right:90deg
  140. to bottom:180deg --默认值
  141. to left:270deg*/
  142.  
  143. /*background: linear-gradient(to right,red,blue)*/;
  144. background: linear-gradient(to right,red 0%,red 50%,blue 50%,blue 100%);
  145. ---------------------
  146. 径向渐变
  147. /*语法:radial-gradient(形状 大小 坐标,颜色1,颜色2...)
  148. 形状shape:circle:产生正方形的渐变色 ellipse:适配当前的形状,如果是正方形的容器,两者效果一样.如果宽高不一样,默认效果切换到ellipse
  149. at position:坐标,默认在正中心。可以赋值坐标(参照元素的左上角),也可以赋值关键字(left center right top bottom)
  150. 大小size: closest-side:最近边; farthest-side:最远边; closest-corner:最近角; farthest-corner:最远角。默认是最远的角farthest-corner*/
  151. /*background: radial-gradient(circle,red,blue);*/
  152. /*background: radial-gradient(circle farthest-side at 50px 50px,red,blue);*/
  153. /*background: radial-gradient(at left top,red,blue);*/
  154. center:渐变起点的位置,可以为百分比,默认是图形的正中心。
  155. shape:渐变的形状,ellipse表示椭圆形,circle表示圆形。默认为ellipse,如果元素形状为正方形的元素,则ellipsecircle显示一样。
  156. size:渐变的大小,即渐变到哪里停止,它有四个值。 closest-side:最近边; farthest-side:最远边; closest-corner:最近角; farthest-corner:最远角
  157. --------------重复渐变-----
  158. div:first-of-type{
  159. width: 300px;
  160. height: 300px;
  161. /*background: radial-gradient(
  162. #fff 0%,#fff 10%,
  163. #000 10%,#000 20%,
  164. #fff 20%,#fff 30%,
  165. #000 30%,#000 40%);*/
  166. background: repeating-radial-gradient(circle closest-side at center center,
  167. #fff 0%,#fff 10%,
  168. #000 10%,#000 20%);
  169. }
  170. div:last-of-type{
  171. width: 200px;
  172. height: 800px;
  173. background: repeating-linear-gradient(45deg,
  174. #fff 0%,#fff 10%,
  175. #000 10%,#000 20%);
  176. }
  177. ------------------------------------
  178. ::before
  179. ::after content必写属性 行内元素 JS无法操作
  180. --------------background-----------------
  181. /*3.设置背景平铺
  182. round:会将图片进行缩放之后再平铺
  183. space:图片不会缩放平铺,只是会在图片之间产生相同的间距值*/
  184. /*background-repeat: space;*/
  185. /*4.设置在滚动容器的背景的行为:跟随滚动/固定
  186. fixed:背景图片的位置固定不变
  187. scroll:当滚动容器的时候,背景图片也会跟随滚动*/
  188.  
  189. /*local和scroll的区别:前提是滚动当前容器的内容
  190. local:背景图片会跟随内容一起滚动
  191. scroll:背景图片不会跟随内容一起滚动*/
  192. background-attachment: scroll;
  193. overflow: scroll; 可以加小窗口
  194. /*cover:与contain刚好相反,背景图片会按比例缩放自 适应整个背景区域,如果背景区域不足以包含所有背景图片,图片内容会溢出
  195. 1.图片大于容器:等比例缩小,会填满整个背景区域,有可能造成图片的某些区域不可见
  196. 2.图片小于容器:等比例放大,填满整个背景区域,图片有可能造成某个方向上内容的溢出*/
  197. background-size:conat 有空白
  198. cover
  199. 让长图片居中 用背景定位居中 cover CSS/进行连接
  200. border-box:从border的位置开始填充背景,会与border重叠
  201. padding-box:从padding的位置开始填充背景,会与padding重叠
  202. content-box:从内容的位置开始填充背景*/
  203. background-origin: content-box;
  204. /*添加边框图片*/
  205. border-image-source: url("../images/btn_bg.png");
  206. /*设置受保护的区域大小*/
  207. border-image-slice: 10 fill;
  208. /*设置边框图片的宽度
  209. 1.明确圆角的大小
  210. 2.明确受保护的区域的大小*/
  211. border-image-width: 10px;
  212. /*设置背景平铺效果 默认是stretch:拉伸*/
  213. border-image-repeat: stretch;
  214. ------------------------------------------------
  215. div:active{}点击
  216. -----------过度动画-----------
  217. /*简写:transition:属性名称 过渡时间 时间函数 延迟*/
  218. /*transition: left 2s linear 0s;*/
  219. /*为多个样式同时添加过渡效果*/
  220. /*transition: left 2s linear 0s,background-color 5s linear 0s;*/
  221.  
  222. /*为所有样式添加过渡效果 all:所有样式
  223. 1.所有样式的过渡效果一样
  224. 2.效率低下,它会去查询所有添加的样式
  225. 3.建议:以后不要这么写
  226. 4.steps(4):可以让过渡效果分为指定的几次来完成*/
  227. transition:all 2s steps(4);
  228. -moz-transition: all 2s steps(4);
  229. -webkit-transition: all 2s steps(4);
  230. -o-transition: all 2s steps(4);
  231. ----------------------------------------------------------------------------------------------------
  232. 二维变换:
  233. /*移动translate*/
  234.  
  235. /*添加过渡效果 css样式名称 耗时*/
  236. transition: transform 2s;
  237. div{
  238. width: 100px;
  239. height: 100px;
  240. background-color: red;
  241. margin-left: 200px;
  242. margin-top:10px;
  243. /*添加过渡效果 css样式名称 耗时*/
  244. transition: transform 2s;
  245. }
  246.  
  247.  
  248. /*添加三维移动--3D移动*/
  249. div:first-of-type:active{
  250. /*translate3d(X方向的偏移,Y方向的偏移,Z方向的偏移)*/
  251. /*transform: translate3d(400px,0,0);*/
  252. /*transform: translate3d(400px,400px,0);*/
  253. transform: translate3d(0px,0px,400px);
  254. }
  255. div:first-of-type:active{
  256. /*使用transform实现元素的移动 a.移动是参照元素的左上角 b.执行完毕之后会恢复到原始状态
  257. 1.如果只有一个参数就代表x方向
  258. 2.如果有两个参数就代表x/y方向*/
  259. /*transform: translate(100px);*/
  260. /*transform: translate(400px,500px);*/
  261. /*transform: translate(0px,500px);*/
  262.  
  263. /*添加水平或者垂直方向的移动*/
  264. /*transform:translateX(300px);*/
  265. transform:translateY(300px);
  266. }
  267. -------------------------------
  268. /*缩放:scale*/
  269.  
  270. /*实现缩放 1指不缩放,>1.01放大 <0.99缩小 参照元素的几何中心
  271. 1.如果只有一个参数,就代表x和y方向都进行相等比例的缩放
  272. 2.如果有两个参数,就代表x/y方向*/
  273. /*transform: scale(2);*/
  274. /*transform: scale(2,1);*/
  275. /*缩放指定的方向 */
  276. /*transform:scaleX(0.5);*/
  277. transform:scaleY(0.5);
  278. /*transform:rotate(-90deg);
  279. transform: translateX(700px);*/
  280. /*同时添加多个transform属性值*/
  281. -------------------------
  282. /*旋转:rotate*/
  283. /*旋转:rotate*/
  284. div:nth-of-type(3){
  285. ----------------------------------
  286. /*设置旋转轴心
  287. 1.x y
  288. 2.关键字:left top right bottom center*/
  289. background-color: purple;
  290. transform-origin: left top;
  291. }
  292. ----------------------------------------------
  293. div:nth-of-type(3):active{
  294. /*transform:rotate(-90deg);
  295. transform: translateX(700px);*/
  296. /*同时添加多个transform属性值*/
  297. transform: translateX(700px) rotate(-90deg);
  298. /*transform: rotate(-90deg) translateX(700px);*/
  299. 实现任意元素居中:
  300. /*使用transform实现元素的居中 百分比是参照元素本身的宽高*/
  301. transform: translate(-50%,-50%);
  302. /*transform: translate(-50px,-50px);*/
  303. --------------------
  304. /*斜切:skew*/
  305. div:nth-of-type(4):active{
  306. background-color: blue;
  307. /*如果角度为正,则往当前轴的负方向斜切,如果角度为,则往当前轴的正方向斜切*/
  308. transform:skew(-30deg);
  309. /*transform:skew(30deg,-30deg);*/
  310. /*设置某个方向的斜切值*/
  311. /*transform:skewX(30deg);*/
  312. /*transform:skewY(30deg);*/
  313. }
  314. ---------------------三维移动----------------------------------------
  315. div{
  316. width: 100px;
  317. height: 100px;
  318. background-color: red;
  319. margin-left: 200px;
  320. margin-top:10px;
  321. /*添加过渡*/
  322. transform: rotate3d(1,1,0,30deg);
  323. /*让子元素保留3d变换之后的效果*/
  324. transform-style: preserve-3d;
  325. transition: transform 2s;
  326. }
  327. /*添加三维移动--3D移动*/
  328. div:first-of-type:active{
  329. /*translate3d(X方向的偏移,Y方向的偏移,Z方向的偏移)*/
  330. /*transform: translate3d(400px,0,0);*/
  331. /*transform: translate3d(400px,400px,0);*/
  332. transform: translate3d(0px,0px,400px);
  333. }
  334. /*添加三维缩放*/
  335. div:nth-of-type(2):active{
  336. /*scale3d(x方向上的缩放,y方向的缩放,z方向的缩放)
  337. >1.01 放大 <0.99 缩小*/
  338. /*transform:scale3d(2,0.5,10);*/
  339. transform:scale3d(1,1,10);
  340. }
  341. /*添加三维旋转*/
  342. div:nth-of-type(3):active{
  343. /*rotate3d(x,y,z,angle):
  344. x:代表x轴方向上的一个向量值
  345. y:代表y轴方向上的一个向量值
  346. z:代表z轴方向上的一个向量值*/
  347. transform: rotate3d(1,1,1,330deg);
  348. }
  349. ---------------
  350. .box{
  351. width: 200px;
  352. height: 200px;
  353. margin:100px auto;
  354. position: relative;
  355. /*让box默认旋转,方便观察*/
  356. transform: rotate3d(1,1,0,0deg);
  357. /*让子元素保留3d变换之后的效果*/
  358. transform-style: preserve-3d;
  359. /*添加透视景深效果*/
  360. perspective: 0px;
  361. /*设置透视的观察角度*/
  362. perspective-origin: 0px 0px;
  363. }
  364. ----------------------------------------
  1. div {
  2. width: 200px;
  3. height: 100px;
  4. background-color: pink;
  5. /* transition: 要过渡的属性 花费时间 运动曲线 何时开始; */
  6. transition: width 0.6s ease 0s, height 0.3s ease-in 1s;
  7. /* transtion 过渡的意思 这句话写到div里面而不是 hover里面 */
  8. }
  9. div:hover { /* 鼠标经过盒子,我们的宽度变为400 */
  10. width: 600px;
  11. height: 300px
  12. }
  13. transition: all 0.6s; /* 所有属性都变化用all 就可以了 后面俩个属性可以省略 */
  14. animation: rotate 2s linear infinite;//旋转
  15. -webkit-transform: rotate(360deg);
  16. -moz-transform: rotate(360deg);
  17. -ms-transform: rotate(360deg);
  18. -o-transform: rotate(360deg);
  19. transform: rotate(360deg);
  20. -------------------旋转----------------
  21. @-webkit-keyframes rotation{
  22. from {-webkit-transform: rotate(0deg);}
  23. to {-webkit-transform: rotate(360deg);}
  24. }
  25. .Rotation{
  26. -webkit-transform: rotate(360deg);
  27. animation: rotation 3s linear infinite;
  28. -moz-animation: rotation 3s linear infinite;
  29. -webkit-animation: rotation 3s linear infinite;
  30. -o-animation: rotation 3s linear infinite;
  31. }
  32. focus 聚焦
  33. !important 我最大 层级级别最高
  34. transition 过渡动画
  35. transform 2D变形
  36. translate 位移
  37. rotate 旋转
  38. scale 缩放
  39. skew 斜切
  40. transform-origin 旋转中心点
  41. perspective 透视
  42. ---------------------------------------动画------------
  43. 动画可以添加多个关键帧
  44. --------------------------
  45. 设置列数
  46. column-count:3;
  47. -----------------------伸缩布局--------------
  48. /*flex-flow:是flex-wrap和flex-direction的综合
  49. flex-wrap:控制子元素是否换行显示,默认不换行
  50. nowrap:不换行--则收缩
  51. wrap:换行
  52. wrap-reverse:翻转,原来是从上到下,翻转后就是从下到上来排列*/
  53. /*flex-wrap: wrap;*/
  54. /*flex-direction:设置子元素的排列方向:就是用来主轴方向,默认主轴方向是row(水平方向)
  55. row:水平排列方向,从左到右
  56. row-reverse:水平排列方向,从右到左
  57. column:垂直排列方向,从上到下
  58. column-reverse:垂直排列方向,从下到上*/
  59. /*flex-direction: column-reverse;*/
  60. ----------------伸缩------计算剩余空间------------
  61. /*flow-grow:可以来扩展子元素的宽度:设置当前元素应该占据剩余空间的比例值
  62. 比例值计算 :当前空间的flex-grow/所有兄弟元素的flex-grow的和
  63. flex-grow的默认是0:说明子元素并不会去占据剩余的空间*/
  64. flex-grow: 1;
  65. ----------------伸缩------收缩------------
  66. /*设置父容器为盒子:会使每一个子元素自动变成伸缩项
  67. 当子元素的宽度和大于父容器宽度的时候,子元素会自动平均收缩*/
  68. display: flex;
  69. /*设置子元素的主轴方向上的排列方式*/
  70. justify-content: space-around;
  71. /*flex-shrink:定义收缩比例,通过设置的值来计算收缩空间
  72. 比例值计算 :当前空间的flex-shrink/所有兄弟元素的flex-shrink的和
  73. 默认值为1*/
  74. flex-shrink: 2;
  75. 计算公式:把所有子元素的和 - 父元素/flex-shrink: 2 =分配的值
  76. ------------------------------flex-------------------
  77. .box{
  78. width: 100%;
  79. height: 500px;
  80. background-color: #ccc;
  81. margin:0 auto;
  82. /*设置父容器的为伸缩盒子*/
  83. display: flex;
  84. /*设置子元素在主轴方向上的排列方式*/
  85. /*justify-content: flex-start;*/
  86. }
  87. .left{
  88. /*flex是用来设置当前伸缩子项占据剩余空间的比例值*/
  89. flex: 1;
  90. height: 500px;
  91. background-color: red;
  92. }
  93. .right{
  94. flex: 4;
  95. height: 500px;
  96. background-color: blue;
  97. }
  98. ---------------------------------------------
  99. /*设置父容器为盒子:会使每一个子元素自动变成伸缩项
  100. 当子元素的宽度和大于父容器宽度的时候,子元素会自动平均收缩*/
  101. display: flex;
  102. /*设置子元素的主轴方向上的排列方式*/
  103. justify-content: space-around;
  104. /*align-items:设置子元素(伸缩项)在侧轴方向上的对齐方式
  105. center:设置在侧轴方向上居中对齐
  106. flex-start:设置在侧轴方向上顶对齐
  107. flex:end:设置在侧轴方向上底对齐
  108. stretch:拉伸:让子元素在侧轴方向上进行拉伸,填充满整个侧轴方向>> 默认值
  109. baseline:文本基线*/
  110. ------------------------------------------
  111. 2D
  112. transition: 属性名 过渡时间 延迟时间 动画速度 steps(2))
  113. transform: translate(x,y)
  114. transform: rotate(30deg)
  115. transform: scale(2)
  116. transform: skew(20deg) 了解
  117. 3d:
  118. transform-style:preserve-3d;
  119. ---------------------------------------------
  120. 1、动画的实现
  121. animation-name: moveTest;
  122. animation-duration: 2s;
  123. scale放大
  124. @keyframes moveTest{
  125. 0%{}
  126. 20%{}
  127. 100%{}
  128. }
  129. 2animation-fill-mode
  130. 有延迟
  131. animation-fill-mode:forwards 0%动画不会立刻执行,结束时会停留在结束状态
  132. animation-fill-mode:backwards 0%动画会立刻执行, 结束时不会停留在结束状态
  133. animation-fill-mode:both 0%动画会立刻执行, 结束时会停留在结束状态
  134. 没有延迟
  135. animation-fill-mode:forwards 0%动画会立刻执行,结束时会停留在结束状态
  136. animation-fill-mode:backwards 0%动画会立刻执行, 结束时不会停留在结束状态
  137. animation-fill-mode:both 0%动画会立刻执行, 结束时会停留在结束状态
  138. list-style: none;
  139. /*1.设置的名称*/
  140. animation-name: move;
  141. /*2.设置动画的耗时*/
  142. animation-duration: 7s;
  143. /*3.市场无限循环*/
  144. animation-iteration-count: infinite;
  145. /*4.设置时间函数*/
  146. animation-timing-function: linear;
  147. 3animation:动画名 动画时间 动画的延迟时间 动画的速度 次数(infinite) forwards
  148. @keyframes 动画名{
  149. 0%{}=====from{}
  150. 100%{}=====to{}
  151. }
  152. -------------------------------------------
  153. @keyframes Animation{
  154. from{
  155. transform: rotate3d(1,1,1,-30deg) rotateY(0);
  156. }
  157. to{
  158. transform: rotate3d(1,1,1,-140deg) rotateY(360deg);
  159. }
  160. }
  161. ----------------------------------------------------------
  162. 4、弹性布局 开启弹性布局===============display:flex
  163. 父元素:
  164. display:flex
  165. justify-content:flex-start || flex-end || center || space-around(两边会有间距) || space-between(两边不会有间距)
  166. flex-wrap:wrap 显示换行
  167. flex-direction:column 竖直方向变成主轴水平方向变成侧轴 默认是flex-direction:row 水平方向为主轴
  168. align-itemsflex-start || center || flex-end
  169. 子元素:
  170. flex-grow || flex-shrink (不需要记住)
  171. flex1 这个是占父盒子剩余空间的
  172. align-self: flex-start || center || flex-end
  173. justify-content 左中右
  174. align-items 上中下
  175. 使用animation+@keyframes 不需要你使用transition 因为@keyframes 有关键帧可以使动画连续
  176. a:active{
  177. 加上旋转 此时不会产生有连续的动画 ====需要加上属性transition
  178. }
  179. -------------------------
  180. border-left-color: red;
  181. border-right-color: black;
  182. border-top-color: yellow;
  183. 给边框加颜色
  184. ----------------------------
  1.  

 

  1.  

 

div {width: 200px;height: 100px;background-color: pink;/* transition: 要过渡的属性  花费时间  运动曲线  何时开始; */transition: width 0.6s ease 0s, height 0.3s ease-in 1s;/* transtion 过渡的意思  这句话写到div里面而不是 hover里面 */  }div:hover {  /* 鼠标经过盒子,我们的宽度变为400 */
width: 600px;height: 300px}
transition: all 0.6s;  /* 所有属性都变化用all 就可以了  后面俩个属性可以省略 */
animation: rotate 2s linear infinite;//旋转    -webkit-transform: rotate(360deg);            -moz-transform: rotate(360deg);            -ms-transform: rotate(360deg);            -o-transform: rotate(360deg);            transform: rotate(360deg);
-------------------旋转----------------@-webkit-keyframes rotation{from {-webkit-transform: rotate(0deg);}to {-webkit-transform: rotate(360deg);}}
.Rotation{-webkit-transform: rotate(360deg);animation: rotation 3s linear infinite;-moz-animation: rotation 3s linear infinite;-webkit-animation: rotation 3s linear infinite;-o-animation: rotation 3s linear infinite;}
focus 聚焦

!important  我最大  层级级别最高
transition    过渡动画transform    2D变形translate     位移rotate       旋转scale        缩放skew        斜切transform-origin  旋转中心点perspective    透视

---------------------------------------动画------------动画可以添加多个关键帧


--------------------------设置列数column-count:3;-----------------------伸缩布局-------------- /*flex-flow:是flex-wrap和flex-direction的综合            flex-wrap:控制子元素是否换行显示,默认不换行                nowrap:不换行--则收缩                wrap:换行                wrap-reverse:翻转,原来是从上到下,翻转后就是从下到上来排列*/            /*flex-wrap: wrap;*/            /*flex-direction:设置子元素的排列方向:就是用来主轴方向,默认主轴方向是row(水平方向)                row:水平排列方向,从左到右                row-reverse:水平排列方向,从右到左                column:垂直排列方向,从上到下                column-reverse:垂直排列方向,从下到上*/            /*flex-direction: column-reverse;*/
----------------伸缩------计算剩余空间------------/*flow-grow:可以来扩展子元素的宽度:设置当前元素应该占据剩余空间的比例值            比例值计算 :当前空间的flex-grow/所有兄弟元素的flex-grow的和            flex-grow的默认是0:说明子元素并不会去占据剩余的空间*/            flex-grow: 1;----------------伸缩------收缩------------/*设置父容器为盒子:会使每一个子元素自动变成伸缩项             当子元素的宽度和大于父容器宽度的时候,子元素会自动平均收缩*/            display: flex;            /*设置子元素的主轴方向上的排列方式*/            justify-content: space-around;/*flex-shrink:定义收缩比例,通过设置的值来计算收缩空间             比例值计算 :当前空间的flex-shrink/所有兄弟元素的flex-shrink的和            默认值为1*/            flex-shrink: 2;
计算公式:把所有子元素的和 - 父元素/flex-shrink: 2 =分配的值------------------------------flex-------------------

.box{            width: 100%;            height: 500px;            background-color: #ccc;            margin:0 auto;            /*设置父容器的为伸缩盒子*/            display: flex;            /*设置子元素在主轴方向上的排列方式*/            /*justify-content: flex-start;*/        }        .left{            /*flex是用来设置当前伸缩子项占据剩余空间的比例值*/            flex: 1;            height: 500px;            background-color: red;        }        .right{            flex: 4;            height: 500px;            background-color: blue;        }
---------------------------------------------            /*设置父容器为盒子:会使每一个子元素自动变成伸缩项             当子元素的宽度和大于父容器宽度的时候,子元素会自动平均收缩*/            display: flex;            /*设置子元素的主轴方向上的排列方式*/            justify-content: space-around;            /*align-items:设置子元素(伸缩项)在侧轴方向上的对齐方式            center:设置在侧轴方向上居中对齐            flex-start:设置在侧轴方向上顶对齐            flex:end:设置在侧轴方向上底对齐            stretch:拉伸:让子元素在侧轴方向上进行拉伸,填充满整个侧轴方向>> 默认值            baseline:文本基线*/------------------------------------------
  2D:                transition:  属性名   过渡时间  延迟时间  动画速度  (steps(2))                transform: translate(x,y)                transform: rotate(30deg)                transform: scale(2)                transform: skew(20deg)   了解
            3d:                transform-style:preserve-3d;
---------------------------------------------        1、动画的实现            animation-name: moveTest;            animation-duration: 2s;scale放大            @keyframes  moveTest{                0%{}                20%{}                100%{}            }

        2、animation-fill-mode            有延迟                animation-fill-mode:forwards    0%动画不会立刻执行,结束时会停留在结束状态                animation-fill-mode:backwards   0%动画会立刻执行,  结束时不会停留在结束状态                animation-fill-mode:both        0%动画会立刻执行,  结束时会停留在结束状态
            没有延迟                animation-fill-mode:forwards     0%动画会立刻执行,结束时会停留在结束状态                animation-fill-mode:backwards    0%动画会立刻执行,  结束时不会停留在结束状态                animation-fill-mode:both         0%动画会立刻执行,  结束时会停留在结束状态

 list-style: none;            /*1.设置的名称*/            animation-name: move;            /*2.设置动画的耗时*/            animation-duration: 7s;            /*3.市场无限循环*/            animation-iteration-count: infinite;            /*4.设置时间函数*/            animation-timing-function: linear;        3、animation:动画名 动画时间  动画的延迟时间  动画的速度  次数(infinite)  forwards
            @keyframes  动画名{                0%{}=====from{}                100%{}=====to{}            }-------------------------------------------        @keyframes Animation{            from{                transform: rotate3d(1,1,1,-30deg)  rotateY(0);            }            to{                transform: rotate3d(1,1,1,-140deg) rotateY(360deg);            }        }----------------------------------------------------------        4、弹性布局    开启弹性布局===============display:flex        父元素:            display:flex            justify-content:flex-start || flex-end ||  center || space-around(两边会有间距) ||  space-between(两边不会有间距)            flex-wrap:wrap  显示换行            flex-direction:column   竖直方向变成主轴水平方向变成侧轴       默认是flex-direction:row 水平方向为主轴
            align-items:flex-start  ||  center || flex-end        子元素:            flex-grow ||  flex-shrink     (不需要记住)            flex:1    这个是占父盒子剩余空间的            align-self: flex-start  ||  center || flex-end
        justify-content  左中右        align-items     上中下




        使用animation+@keyframes   不需要你使用transition     因为@keyframes 有关键帧可以使动画连续        a:active{            加上旋转  此时不会产生有连续的动画  ====需要加上属性transition         }
-------------------------border-left-color: red;            border-right-color: black;            border-top-color: yellow;给边框加颜色----------------------------

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号