WEB前端复习——CSS

CSS:层叠样式表 将显示样式与内容分开

基本语法:

选择器{

规则;

}

①标签选择器:以HTML标签名为选择

复制代码
<style>
    p{
        color: red;
    }
</style>
<body>
   <p>你好</p>
</body>

②id选择器:一次性的 以#号定义

复制代码
<style>
    #p1{
        color: red;
    }
</style>
<body>
    <p>2</p>
   <p id="p1">你好</p>
</body>

③类选择器(单类、多类)用"."标识

复制代码
<style>
    .p3{
        color: red;
    }
</style>
<body>
    <p>2</p>
   <p class="p3">你好</p>
</body>

(或p.p3{})

④属性选择器 ahref{} :a标签含href才变色 ahref="URL" 指定url的a标签才变色

派生选择器:li strong{} li元素中的strong元素样式变色


常用字体属性:

font-size:20px

font-style:italic

font-weight:bold

font-family:宋体

文本属性

text-align

列表属性

list-style-type

背景

color

background-color

background-image


HTML引入CSS

1 在<style>标签内定义

2 <div style="background-color:red"><div>

3 <head>中引入外部css文件

<head>

<title>Document</title>

<link type="text/css" rel="name" href="URL.css">

</head>


盒子模型: margin border padding content (top left right bottom)

浮动: float left right

clean:both

相关推荐
无限聚核8 分钟前
抖音 certificate.prepare 之后怎么验券?和美团 msconsume 差在哪,无限聚核
前端·微信小程序
2603_9658966218 分钟前
Grid 网格布局|CSS 二维页面排版体系
前端·css
有味道的男人34 分钟前
搜好货平台关键词商品搜索接口:分页容错与商品数据轻量化提取方案
服务器·前端·javascript
lovingsoft1 小时前
Chrome Lighthouse 详解
前端·chrome
Qlly1 小时前
全栈工程师怎么接需求?从一句「加个功能」聊到能开发、能验收
前端·后端
多喝水身体棒1 小时前
# CSS Grid布局入门,二维布局再也不用float了
css
马可家的菠萝1 小时前
你的微信“文件传输助手”,是不是已经成了第二个网盘?
前端·后端·架构
略略略啦1 小时前
Vibe Coding 基于Spec DD和TDD的实践指南
前端
shmily麻瓜小菜鸡2 小时前
前端实现图片与PDF文字识别敏感信息打码方案
前端·pdf·状态模式
打工仔折腾 AI2 小时前
LangChain 工具调用实战:从 Tool 定义到 Agent 执行链路拆解
java·前端·人工智能·后端·python·langchain·ai agent 实战