css3-学习

css 特性

选择器

基础选择器

标签选择器

ID 选择器

类选择器

CSS 的优先级是什么?

!important > 内联样式(style="") > ID 选择器 > 类选择器 = 属性选择器 = 伪类 > 标签选择器 = 伪元素选择器。

层级选择器

  • foo bar 后代选择器,元素的后代元素
  • foo > bar 子代选择器,元素的子代元素
  • foo + bar 相邻同胞选择器
  • foo ~ bar 通用同胞选择器
  • foo, bar 并集选择器
  • foo.class 交集选择器

条件选择器

:lang 具体语言标记的元素

:dir() 指定编写方向的元素

:has 包括指定元素的元素

:is 指定条件的元素

:not 非指定条件的元素

:where 指定条件的元素

状态选择器

:active

:hover

:link

:visited

:focus

表单

:valid

:invalid

:checked switch

结构选择器

:root 文档的根元素

:empty 无子元素的元素

:nth-child(n) 元素中指定顺序索引的元素。odd/even

:nth-last-child(n) 倒序索引

:first-child 元素中为首的元素

:last-child 元素中为尾的元素

:only-child 仅有该元素的元素

属性选择器

attr 指定属性的元素

attr=val 属性等于指定值的元素

attr\*=val 包括指定元素的元素

attr\^=val 包括开头

attr$=val 包括结尾

伪元素

::before 在元素前加入

::after 在元素后面加入

::first-letter

::first-line

::backdrop 全屏模式的元素 (Document.fullscreen)

::placeholder

html 复制代码
<div class="t1">
    <span>hello</span>luyi<span>teather</span>
</div>
<div class="t2">luyi</div>
<style>
    .t2::before {
        content:'hello'
    }
    .t2::after {
        content:'teacher'
    }
</style>

flex 布局

flex -- flexible box 弹性布局。

display: flex

容器属性

  • flex-direction 主轴的方向
    • row -- default
    • column
  • flex-wrap 如果一个轴线排不下,如何换行
    • nowrap -- default
    • wrap
    • wrap-reverse
  • flex-flow 是以上两者的简写
  • justify-content
    • flex-start
    • flex-end
    • center
    • space-between
    • space-around
    • space-evenly
  • align-items
    • flex-start
    • flex-end
    • center
    • baseline 项目的第一行文字的基线对齐
    • stretch 占满高度

项目属性

  • order

    • 属性定义项目的排列顺序,数值越小,排列越靠前,默认为0.
  • flex-grow

    • 放大比例,剩余空间。默认为0;
  • flex-shrink

    • 缩小比例,剩余空间,默认为1;
  • flex-basis

    • 定义在分配多余空间之前,项目占据的空间。
  • flex

    • flex: 1 是什么意思
      • 如果直接赋值数字,flex:1 -- flex: 1 1 0%
      • 如果给 auto, flex: auto -- flex: 1 1 auto
      • flex:none flex: 0 0 none

动画和变换

tranform, transition, animation

transfrom

变换,2d 变换、3d 变化

  • transfrom
    • flat
    • preserve-3d
translate 平移

translate(x, y)

translate3d(x, y, z) -- translateZ(0)

scale 缩放

scale(x,y)

scale3d(x, y, z)

skew 扭曲
rotate 旋转

rotate()

rotate(x, y, z, a)

transition

transition-property
  • all
  • none
  • string
transition-duration

持续时间

transition-timimg-function
transition-delay

animation

name

有一个动画的名称

duration

持续时间

timimg-function
delay
播放次数
相关推荐
GreenTea6 小时前
GrokBot 核心成员 Lauren Tan:每月交付 2000 个 PR 的人,是怎么用 AI 的
前端·后端·架构
mCell7 小时前
用 Knip 清理 AI Coding 留下的冗余代码
前端·ai编程·前端工程化
小弥儿7 小时前
GitHub今日热榜 | 2026-09-18:腾讯双项目上榜
学习·开源
笃行3508 小时前
使用Rokid AIUI做了一个童年推箱子游戏
前端
excel9 小时前
前端加密的作用与使用场景
前端
知识分享小能手10 小时前
深度学习学习教程,从入门到精通,深度生成模型 —— 知识点详解与代码实现(20)
人工智能·深度学习·学习
m4Rk_10 小时前
【论文阅读】Agent 记忆机制(74):CompassMem——从相似度检索走向事件图上的记忆导航
论文阅读·人工智能·学习·开源·github
小李不想当小白10 小时前
DMA直接存储器存取(STM32标准库学习笔记)
笔记·stm32·单片机·嵌入式硬件·学习·分享
计算机魔术师10 小时前
纽约时报版权诉讼披露:微软高管内部称训练 AI 是人类历史上最大规模劳动窃取
前端
去伪存真11 小时前
大模型的参数量为什么那么大?
前端·人工智能