第三次预习——css基础,选择器,盒子模型

css基础

1.css基本语法:

p(选择器){    
   color(属性名):red(属性值);
}

2.三种使用方法

  • 内联样式<style></style>(页面内书写,页面内使用)
<style type="text/css">
  p{
     color:red;
   }
</style>
  • 外联样式

<link/>(单独一个css文件,使用时引用)

<link rel="stylesheet" type="text/css" href="index.css(css文件)"/>

import(一种在css中引入css的方式)

@import"./css/xxxxx.css"(文件的地址)
  • 行内样式(标签内写,只对这个标签起作用)
<p style="color:red"></p>

选择器

1.css类名规范:

  • 不能以数字开头
  • 可以的特殊符号为下划线和横杠

2.基本选择器

  • 通配选择器:* (所有标签内元素都会改变)
<style type="text/css">
*{
   color:red;
 }
</style>
  • 元素选择器:(对标签内元素改变)
<style type="text/css">
p{
  color:red;
 }
</style>
  • id选择器
<head>
  <style type="text/css">
    #page{
           color:red;
         }
  </style>
</head>
<body>
   <p id="page"></p>
</body>
  • class选择器
<head>
  <style type="text/css">
     .text{
           color:red;
          }
  </style>
</head>
<body>
  <p class="text"></p>
</body>
  • 群组选择器
<head>
  <style type="text/css">
     .list1 , .list2{       ----->两个列表应用相同的样式
           color:red;
           } 
  </style>
</head>
<body>
  <ul id="ul1">
    <li class="list1"></li>---------->内容为红色
    <li class="list1"></li>---------->内容为红色
  &l
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值