CSS入门

前端学习的第三天

  1. 引入CSS:
    • 使用style标签(调试代码使用)
		<style>
			p{
				color : #FF0000;
			}
		</style>
- 使用link标签  `<link rel="stylesheet" type="text/css" href="css/syle.css" />`
- 使用style属性
  1. 基本语法
选择器{
	属性: 属性值
	属性: 属性值
}
  1. 普通选择器
  2. 元素选择器: 直接使用标签名就行
  3. class选择器: 标签加入class属性class="my" 加入属性的方法: 使用点(.)加class
.my{
 color : #FF0000;
}
  1. ID选择器尽量不要用 使用#加ID值

  2. 优先级为ID>class>元素选择器

  3. 特殊选择器

  4. 并集选择器: 选择器, 选择器{ } h1,.myclaa

  5. 交集选择器: (元素)选择器选择器{ } p.myclass

  6. 后代选择器 选择器 选择器 .div1 p

  7. 子代选择器 选择器>选择器 .div1>p

  8. 属性选择器 [属性] 或 [属性=‘属性值’]

  9. 全局选择器 * 做统一设置时使用

  10. 伪类选择器 (选择元素的状态:hover :active)

  11. 常用样式属性

    • color: #FF0000;

    • width: 100px;

    • height: 100px;

    • border: 1px solid black;

    • background-color: whiter;

    • background: url(dir);

    • background-repeat: no-repeat

    • font-size: 44px;

    • font-family: “宋体”;

    • text-decoration: none;(文字修饰)

    • text-align: center;

    • line-height: 600px;

    • list-style: circle;

    • display: block(从上到下排列) inline(行内 从左在右) inlin-block(行内块) none(不显示元素)

    • opacity: 0.5(透明度, 为半透明)

    • overflow: hide; (处理超出边界)

    • float: left;(浮动排列元素)

    • margin: 10px auto (外边距)

    • padding: 10px (内容和边框的距离)

    • padding-left: 5px

    • border-radius: 10px(圆角边框)

    • position

      1. 相对定位
		.c1{
				position: relative;
				left: 20px;
				top: 20px;
			}	
   2. 绝对定位 以页面位置进行偏移
		.c1{
				position: absolute;
				left: 20px;
				top: 20px;
			}	
   3. 默认定位: static 块从上到下 行内 从左到右
   4. 固定定位: fixed 已屏幕的位置进行偏移 适合做小广告
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值