css 基本

2019-03-14  本文已影响0人  downhill6

css基本

在HTML中使用CSS(引入CSS)

内联(inline style attribute)
<head> 标签内的 <style> 标签
<link> 标签中的外联

样式优先级(从高到低)

!important
内联样式
<style> 中的样式
link 中的样式

选择器

没有选择器就没法确定样式的作用范围,毫无重点的加样式,最后只会是一锅粥。所以熟练使用选择器是必备技能。

核心选择器

核心选择方式

选择器优先级(从高到低)

!important
内联样式
id 选择器
class 选择器
元素选择器

核心属性

display (显示方式)

float (浮动)

盒模型

content
padding
border
margin

position (元素定位)

static relative absolute fixed

非 static 元素可以用 top left bottom right 属性来设置坐标
relative 是相对定位,原位置仍然留有空间
absolute 完全绝对定位, 忽略其他所有东西, 往上浮动到非 static 的元素
fixed 基于 window 的绝对定位, 不随页面滚动改变
上一篇下一篇

猜你喜欢

热点阅读