web技术:CSS基础知识

简介

CSS指层叠样式表 (Cascading Style Sheets)。
CSS语法由两个主要的部分构成:选择器(HTML元素),以及一条或多条声明

/*添加注释*/
selector, ...selector5 {
  property: value;
  ...
} 

p {
  color: red;
  text-align: center;
}
  • 标签选择器:A {}
  • id选择器:#name {}
  • 类选择器:.name {}
  • 派生选择器:A B {}
  • .name A {} 或 #name A {}
  • 属性选择器:[属性] {}、[属性=xxx] {}、[属性~=xxx] {}
  • A>B {}
  • 通用选择器:* {}
  • 相邻选择器:A+B {}
  • A~B {}

CSS的创建

内联样式 > 内部样式 > 外部样式 > 浏览器默认样式
外部样式:

<head>
  <link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

内部样式:

<head>
  <style>
    hr {
      color: red;
    }
    p {
      margin-left: 10px;
    }
    body {
      background-image: url("images/xxx.gif");
    }
  </style>
</head>

内联样式:

<p style="color: red;margin-top: 10px">这是一个段落</p>

背景(background)

属性说明版本
background
background-attachment
background-color
background-image
background-position
background-repeat

文本(text)

属性说明版本
color颜色red、#ff0000、rgb(255,0,0)、inheritCSS1
direction方向ltr(默认)、rtl、inheritCSS2
line-height行高CSS1
letter-spacing
text-align
text-decoration向文本添加修饰
text-indent缩进元素中文本的首行
text-shadow
text-transform
unicode-bidi
white-space
word-spacing

字体(font)

属性说明版本
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-variant
font-weight粗细

链接

列表(list)

表格

轮廓(outline)

position(定位)

overflow

float(浮动)

CSS发展历程

CSS3

2005年12月,W3C开始CSS3标准的制定。

参考

https://www.w3school.com.cn/index.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值