APP下载

css基础系列

消息来源:baojiabao.com 作者: 发布时间:2024-05-15

报价宝综合消息css基础系列

盒子模型

盒子模型的概念高和宽的设定边框的设定内边距的设定外边距的设定盒子的计算元素显示的方式

image.png

盒子模型:

border边框,margin外边距,padding内部距,content内容,width宽度。

高度:

height: 长度值|百分比|auto

最大高度:

max-height: 长度值|百分比|auto

最小高度:

min-height:长度值|百分比|auto

image.png

image.png

边框的属性:

边框宽度:border-width

边框颜色:border-color

边框样式:border-style

image.png

image.png

边框属性:

border- left | right | top | bottom -width

border ... -color

border ... -style

image.png

image.png

image.png

image.png

image.png

content+padding = ie

image.png

doctype html 宣告

display属性

inline显示内联元素,元素前后没有换行符

block显示块级元素,元素前后有换行符

内联元素使用width和height属性有效。

inline-block行内块元素。

ie 盒子模型和标准 w3c 盒子模型

inline-block 行内块元素,元素呈现为inline,具有block相依特性,none元素不会被显示。

css文字样式:

text-align设定元素内文字的水平对齐方式。

text-align:

left|right|center|justify

style="text-align:left;"

div{text-align:center;}

image.png

文字基线:

image.png

image.png

line-height属性

设定元素中文字行高

语法:

line-height:长度值|百分比

浏览器有预设的行高,不同浏览器预设行高不一样。

word-spacing 设定元素内单词之间的间距

letter-spacing 设定元素内字母之间的间距

image.png

image.png

image.png

文字样式:字型,font-family和font-size。

image.png

image.png

文字粗细:

font-weight:normal|bold|bolder|lighter|100到900

文字样式:

font-style:normal|italic|oblique

水平对齐:

text-align: left|right|center|justify

背景,列表

image.png

背景图片重复问题:

设定元素的背景图片重复方式:

background-repeat: repeat | no-repeat | repeat-x | repeat-y

背景图片显示方式:

设定元素的背景图片的显示方式:

background-attachment: scroll | fixed

scroll: 预设值,背景图片随滚动条滚动

fixed:当页面的其余部分滚动时,背景图片不会移动

背景图片定位:

设定元素的背景图片的位置:

background-position:百分比|值|top|right|bottom|left|center

image.png

image.png

列表:

image.png

list-style-position: inside | outside

image.png

css中的float

float:left;

float:right;

float:none;

float:inherit;

浮动变块状元素,浮动能环绕效果。

image.png

定位css

标准流,定位,浮动

浮动的问题如何解决

手动给父元素新增高度

通过clear清除内部和外部浮动

给父元素新增overfloat属性并结合zoom:1使用

给父元素新增浮动

css中的position

image.png

css背景与列表

css背景样式

background-color:设定元素的背景颜色

background-image:把影象设定为背景

background-position:设定背景影象的起始位置

background-attachment:背景影象是否固定或者随着页面的其余部分滚动

background-repeat:设定背景影象是否重复以及如何重复

background:背景属性设定

css列表样式

list-style-type:设定列表项标志的型别

list-style-image:将影象设定为列表项标志

list-style-position:设定列表中列表项标志的位置

list-style:简写

背景样式

设定背景颜色和背景图片

背景颜色,设定元素的背景颜色

background-color:颜色 | transparent

背景图片

设定元素的背景图片

background-image: url | none

背景图片重复

background-repeat: repeat | no-repeat | repeat-x | repeat-y

背景图片显示的方式

设定元素的背景图片的显示方式

background-attachment: scroll | fixed

scroll:随着滚动条滚动,fixed:背景图片不会移动

背景图片定位

background-position: 百分比 | 值 | top | right | bottom | left | center

background: background-color background-image background-repeat background-attachment background-postion

列表项,list-style-type:关键字 | none

list-style-image: url | none

list-style-position : inside | outside

list-style: list-style-type list-style-position list-style-image

div, ul, li, dl, dt, dd, img

html,css,javascript关系

html是网页内容的载体,css样式是表现,javascript是行为。

css优先级

行内样式>内部>外部

css选择器

标签选择器,全域性选择器,类选择器,群组选择器,id选择器,后代选择器

群组选择器

image.png

image.png

连结伪类

:link 未访问

:visited 已经访问

:hover 鼠标悬停

:active 启用

css继承和层叠

从父元素那继承部分css属性

css层叠可以定义多个样式

选择器的权重

标签选择器1

类和伪类10

id选择器100

万用字元0

行内样式1000

image.png

这种宣告高

image.png

id不要滥用,适当使用class

css汇入式@import 外部css样式

css字型和文字样式

文字:字型,字号,颜色,加粗等

文字:行高,对齐方式,文字修饰等

字型:font-family

文字大小:font-size

文字颜色:font-color

文字粗细:font-weight

文字样式:font-style: normal | italic | oblique

水平对齐:

text-align: left | right | center | justify

css中的浮动

float: left | right | none | inherit 继承

css中的position

position: static | relative | absolute | fixed | inherit

使用z-index要有position: absolute

盒子模型:

盒子模型概念,内边距设定,高和宽的设定,边框的设定,外边距设定,盒子的计算,元素显示的方式。

border-width: thin | medium | thick

border-color: 颜色 | transparent

display: inline | block | inline-block | none

2019-10-29 01:56:00

相关文章