CSS 学习笔记

1.支持简写的样式


1.1 Background 属性

  background:[background-color] [background-image] [background-repeat] [background-attachment] [background-position];
描述 默认值
background-color 背景颜色 transparent
background-image 背景图像 none
background-repeat 重复背景图像 repeat
background-attachment 设置固定的背景图像 scroll
background-position 背景图像的位置 0% 0%
 background: #00FF00 url(bgimage.gif) no-repeat fixed top left;

1.2 Padding属性

padding:padding-top padding-right padding-bottom padding-left;
描述 默认值
padding-top 元素上内边距 0
padding-right 元素右内边距 0
padding-bottom 元素下内边距 0
padding-left 元素左内边距 0
//值个数不一样代表的意思不一样
padding: 3px 2px 1px 7px;
//上:3px 右:2px 下:1px 左:7px
padding: 3px 2px 1px;
//上:3px 右:2px 下:1px 左:2px
padding: 3px 2px;
//上:3px 右:2px 下:3px 左:2px
padding: 3px;
//上:3px 右:3px 下:3px 左:3px

1.3 Margin属性

margin:margin-top margin-right margin-bottom margin-left;
描述 默认值
margin-top 元素上外边距 0
margin-right 元素右外边距 0
margin-bottom 元素下外边距 0
margin-left 元素左外边距 0
//值个数不一样代表的意思不一样
margin: 3px 2px 1px 7px;
//上:3px 右:2px 下:1px 左:7px
margin: 3px 2px 1px;
//上:3px 右:2px 下:1px 左:2px
margin: 3px 2px;
//上:3px 右:2px 下:3px 左:2px
margin: 3px;
//上:3px 右:3px 下:3px 左:3px

1.4 Border属性

border:[border-width]  [border-style] [border-color];
//所有边框
border-left:[border-width]  [border-style] [border-color];
//左边框
border-right:[border-width]  [border-style] [border-color];
//右边框
border-top:[border-width]  [border-style] [border-color];
//上边框
border-bottom:[border-width]  [border-style] [border-color];
//下边框
描述 默认值
border-width 边框的宽度 0
border-style 边框的样式 none
border-color 边框的颜色 不指定
 border:5px solid blue;

border-width border-style border-color 单独使用也可以简写,类同Padding Margin

1.5 Outline属性,位于边框边缘的外围

outline:[outline-color] [outline-style] [border-width];
描述 默认值
outline-color 轮廓边框的颜色 invert
outline-style 轮廓边框的样式 none
outline-width 轮廓边框的宽度 medium
 outline:#0F0 none thick;

1.6 Font属性

font:[font-style] [font-variant] [font-weight] [font-size/line-height] [font-family];
描述 默认值
font-style 字体样式 normal
font-variant 小型大写字母文本 normal
font-weight 字体粗细 normal
font-size 字体尺寸 medium
line-height 字体行高 normal
font-family 字体类型 不指定
 font:italic bold 12px/20px arial,sans-serif;

1.7 Transition 属性

transition: [transition-property] [transition-duration] [transition-timing-function] [transition-delay];
描述 默认值
transition-property 过渡效果的 CSS 属性 all
transition-duration 过渡效果时间 0
transition-timing-function 速度曲线 ease
transition-delay 延迟时间 0
transition: width 2s;

1.8 Animation属性

animation: [animation-name] [animation-duration] [animation-timing-function] [animation-delay] [animation-iteration-count] [animation-direction];
描述 默认值
animation-name 规定需要绑定到选择器的 keyframe 名称 none
animation-duration 完成动画所花费的时间 0
animation-timing-function 速度曲线 ease
animation-delay 延迟时间 0
animation-iteration-count 播放的次数 1
animation-direction 是否应该轮流反向播放动画 normal
animation:mymove 5s infinite;

2.包含多个值的样式


2.1 Box-Shadow属性

box-shadow: h-shadow v-shadow [blur] [spread]  [color] [inset];
描述 默认值
h-shadow 水平阴影的位置 0
v-shadow 垂直阴影的位置 0
blur 模糊距离 0
spread 阴影的尺寸 0
color 阴影的颜色 #000
inset 内部阴影(inset)、外部阴影(outset) inset
box-shadow: 10px 10px pink 50px 20px inset;

box-shadow 向框添加一个或多个阴影时,该属性是由逗号分隔的阴影列表

2.2 Border-Image 属性

border-image:[border-image-source] [border-image-slice] [border-image-width] [border-image-outset] [border-image-repeat]
描述 默认值
border-image-source 边框的图片的路径 none
border-image-slice 图片边框向内偏移 100%
border-image-width 图片边框的宽度 1
border-image-outset 边框图像区域超出边框的量 0
border-image-repeat 平铺(repeated)、铺满(rounded)或拉伸(stretched) stretch
border-image:url(border.png) 30 30 round;

2.3 Text-Shadow属性

text-shadow: h-shadow v-shadow [blur] [color];
描述 默认值
h-shadow 水平阴影的位置 0
v-shadow 垂直阴影的位置 0
blur 模糊距离 0
color 阴影的颜色 #000
text-shadow: 5px 5px 5px #FF0000;

text-shadow 向框添加一个或多个阴影时,该属性是由逗号分隔的阴影列表

3.Flex 弹性布局


Flex布局的元素称为 flex container。它的所有子元素称为 flex item。

概念图

容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。
Flex以后,子元素的 floatclearvertical-align属性将失效

3.1 Flex Container属性

描述
flex-direction 主轴的方向 row(默认值):主轴为水平方向,起点在左端。<br />row-reverse:主轴为水平方向,起点在右端。<br />column:主轴为垂直方向,起点在上沿。<br />column-reverse:主轴为垂直方向,起点在下沿。
flex-wrap 如何换行 nowrap(默认):不换行。<br />wrap:换行,第一行在上方。<br />wrap-reverse:换行,第一行在下方
flex-flow [flex-direction] [flex-wrap] row nowrap (默认)
justify-content 主轴上对齐方式 flex-start(默认值):左对齐<br />flex-end:右对齐<br />center: 居中<br />space-between:先两端对齐,后项目之间间隔相等。<br />space-around:项目之间间隔相等。
align-items 交叉轴上对齐方式 flex-start:上对齐。<br />flex-end:下对齐。<br />center:居中。<br />baseline: 项目的第一行文字的基线对齐。<br />stretch(默认值):占满整个容器的高度。
align-content 多轴的对齐方式

3.2 Flex Item属性

描述 默认值
order 排列顺序。数值越小,排列越靠前 0
flex-grow 放大比例 0
flex-shrink 缩小比例 1
flex-basis 占据的main size auto
flex [flex-grow] [flex-shrink] [flex-basis] 0 1 auto
align-self 单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。 auto

引用

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,902评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,037评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,978评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,867评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,763评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,104评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,565评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,236评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,379评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,313评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,363评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,034评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,637评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,719评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,952评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,371评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,948评论 2 341

推荐阅读更多精彩内容

  • 转载请声明 原文链接地址 关注公众号获取更多资讯 第一部分 HTML 第一章 职业规划和前景 职业方向规划定位...
    程序员poetry阅读 16,507评论 32 459
  • 1.CSS基本概念 1.1 CSS的定义 CSS(Cascading Style Sheets)层叠样式表,主要用...
    寥寥十一阅读 1,800评论 0 6
  • 移动开发基本知识点 一.使用rem作为单位 html { font-size: 100px; } @media(m...
    横冲直撞666阅读 3,450评论 0 6
  • 庄子说:古之人,外化而内不化。现在的我好像改变了很多,但是又似乎从来没有改变过,生命要有所坚持,而生存可以随...
    周周ross17909阅读 234评论 0 0
  • 《从你的全世界路过》这个名字咋一听像是在讲爱情,看下去其实它讲的是青春。青春是什么?我想每个人的回答都是不同。看过...
    月芽凌曦阅读 491评论 5 1