Skip to main content
  1. Posts/

Css Guide

·584 words·2 mins· loading · loading · ·
Author
Zhenda
web - This article is part of a series.
Part : This Article

css选择器
#

常用属性
#

属性描述类型
color设置文本颜色color
text-decoration设置文本装饰(如下划线、删除线等)
text-align设置文本对齐方式
font-family设置字体族系font
font-size设置字体大小
font-weight设置字体粗细
line-height设置行高
letter-spacing设置字符间距
background-color设置背景颜色background
background-image设置背景图片
background-size设置背景图片大小
margin外边距margin
padding内边距padding
border边框border
width设置宽度
height设置高度
display元素的显示方式(如block、inline、flex、none等)display
position元素的定位方式(static、relative、absolute、fixed等)position
top, right, bottom, left设置定位元素的位置
float设置浮动
clear清除浮动效果
flex-direction设置Flexbox布局的主轴方向
justify-content设置Flexbox布局主轴上子元素的对齐方式
align-items设置Flexbox布局交叉轴上子元素的对齐方式
grid-template-columns, grid-template-rows设置Grid布局的列和行的大小和数量
grid-column, grid-row设置Grid布局元素所占的列和行范围
transition设置过渡效果
animation设置动画效果
box-shadow设置阴影效果
overflow设置元素内容溢出效果(scroll, hidden, visible)overflow
opacity设置透明度opacity

布局
#

display

  • block 块
  • inline 行内
  • none 隐藏

position

  • static 默认位置
  • relative 相对于默认位置
  • absolute 相对于最近定位的祖先
  • fixed 相对于视图

优先级
#

  • 内联
  • #
  • .
  • 类型(p, div)
  • *

案例
#

分割线样式

<hr style="height:2px;border:none;border-top:2px dotted #185598;" />
<hr style="height:1px;border:none;border-top:1px dashed #0066CC;" />
<hr style="height:1px;border:none;border-top:1px solid #555555;" />
<hr style="height:3px;border:none;border-top:3px double red;" />
<hr style="height:5px;border:none;border-top:5px ridge green;" />
<hr style="height:10px;border:none;border-top:10px groove skyblue;" />

链接 https://www.yisu.com/jc/119190.html

浏览器调试
#

User Agent Stylesheet 是浏览器自带的默认 CSS 样式表。每个浏览器(Chrome、Firefox、Safari 等)都有自己的默认样式,用于在没有任何自定义 CSS 时给 HTML 元素提供基础样式。

  • margin
  • border
  • padding
web - This article is part of a series.
Part : This Article