css三种引入方式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--
1、通过link标签引入外部的css文件
2、在head中通过style标签定义样式
3、在标签中通过style属性定义样式
-->
<!-- <link rel="stylesheet" href="./css/mian.css">-->
<style type="text/css">
div {
color: #fff;
background: blue;
font-size: 24px;
height: 100px;
width: 200px;
}
</style>
</head>
<body>
<!--<div id="box1">-->
<!-- python天下无敌-->
<!--</div>-->
<div id="box2" style="height: 300px;width: 100px;background: yellow">
python天下无敌
</div>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--
1、通过link标签引入外部的css文件
2、在head中通过style标签定义样式
3、在标签中通过style属性定义样式
-->
<!-- <link rel="stylesheet" href="./css/mian.css">-->
<style type="text/css">
div {
color: #fff;
background: blue;
font-size: 24px;
height: 100px;
width: 200px;
}
</style>
</head>
<body>
<!--<div id="box1">-->
<!-- python天下无敌-->
<!--</div>-->
<div id="box2" style="height: 300px;width: 100px;background: yellow">
python天下无敌
</div>
</body>
</html>
css选择器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
li {
color: red;
}
#sp01 {
color: yellow;
}
.box {
height: 300px;
width: 200px;
background: royalblue;
}
</style>
</head>
<body>
<div class="box">
<ul>
<li>111</li>
<li>22</li>
<li>33</li>
<li>44</li>
</ul>
<span id="sp01">python001</span>
</div>
<hr>
<div class="box"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
a,div,p{
color: #FF0000;
font-size: 30px;
}
li{
list-style: none;
}
li:hover{
background: #00FFFF;
}
</style>
</head>
<body>
<a href="">python</<!-- a>
<div>java</div>
<p>python0001</p> -->
<ul>
<li>菜单1</li>
<li>菜单2</li>
<li>菜单3</li>
<li>菜单4</li>
</ul>
</body>
</html>
css背景设置
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*/
body{
height: 10000px;
background-image: url('./images/bj.png');
background-repeat: no-repeat;
background-position:50px 100px;
background-attachment:fixed;
background-size:200px 100px ;
}
.box{
background: red;
}
</style>
</head>
<body>
<div class="box">
musen123
</div>
</body>
</html>
css 文本样式的设置
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
ul li {
font: bold 24px/50px "microsoft yahei";
color: aqua;
}
p {
text-indent: 36px;
}
.box2{
width: 300px;
height: 200px;
background: yellowgreen;
text-align: center;
line-height: 200px;
}
</style>
</head>
<body>
<div class="box">
<ul>
<li>111</li>
<li>222</li>
<li>333</li>
<li>444</li>
<li>5555</li>
</ul>
<p>
CSS:层叠样式表(英文全称:Cascading Style
Sheets)是一种用来表现[HTML](https://baike.baidu.com/item/HTML)或[XML](https://baike.baidu.com/item/XML)(标准通用标记语言的一个子集)等文件样式的计算机语言。CSS不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化,CSS
能够对网页中元素位置的排版进行像素级精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样式编辑的能力
</p>
<div class="box2">
python
</div>
</div>
</body>
</html>
css盒模型
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.box1,.box2,.box3{
background: #00FFFF;
height: 200px;
width: 200px;
margin: auto;
}
.box1{
border: 2px solid #FF0000;
padding: 20px;
}
.box2{
border: 2px double #9ACD32;
}
.box3{
border-right:3px solid antiquewhite ;
}
</style>
</head>
<body>
<div class="box1">
1111
</div>
<div class="box2">
222
</div>
<div class="box3">
3333
</div>
</body>
</html>
css页面布局浮动
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*/
.box1,
.box2,
.box3 {
height: 200px;
width: 200px;
float: left;
margin-left: 20px;
}
.box1 {
background: #00FFFF;
}
.box2 {
background: yellow;
}
.box3 {
background: red;
}
#app{
}
.content{
height: 300px;
background: #000;
}
.clear{
clear: both;
}
</style>
</head>
<body>
<div id="app">
<div class="box1">
1111
</div>
<div class="box2">
222
</div>
<div class="box3">
3333
</div>
<div class="box1">
3333
</div>
<div class="box2">
3333
</div>
<div class="clear"></div>
</div>
<div class="content">
python8888
</div>
</body>
</html>
css定位
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.box11{
height: 200px;
position: relative;
background: yellowgreen;
}
.box1,
.box2,
.box3 {
height: 200px;
width: 200px;
margin-left: 20px;
}
.box1 {
background: #00FFFF;
position: fixed;
left: 20px;
top: 100px;
}
.box2 {
background: yellow;
position: absolute;
left: 200px;
top: 50px;
}
.box3 {
background: red;
}
#app{
position: relative;
height: 2000px;
}
.left,.right{
height: 50px;
width: 20px;
background: blue;
}
.left{
position: absolute;
left: 20px;
top: 40%;
}
.right{
position: absolute;
right: 20px;
top: 40%;
}
</style>
</head>
<body>
<div class="box11">
<div class="left"></div>
<div class="right"></div>
</div>
<div id="app">
<div class="box1">
1111
</div>
<div class="box2">
222
</div>
<div class="box3">
3333
</div>
<div class="clear"></div>
</div>
</body>
</html>
css页面布局案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.box11{
height: 200px;
position: relative;
background: yellowgreen;
}
.box1,
.box2,
.box3 {
height: 200px;
width: 200px;
margin-left: 20px;
}
.box1 {
background: #00FFFF;
position: fixed;
left: 20px;
top: 100px;
}
.box2 {
background: yellow;
position: absolute;
left: 200px;
top: 50px;
}
.box3 {
background: red;
}
#app{
position: relative;
height: 2000px;
}
.left,.right{
height: 50px;
width: 20px;
background: blue;
}
.left{
position: absolute;
left: 20px;
top: 40%;
}
.right{
position: absolute;
right: 20px;
top: 40%;
}
</style>
</head>
<body>
<div class="box11">
<div class="left"></div>
<div class="right"></div>
</div>
<div id="app">
<div class="box1">
1111
</div>
<div class="box2">
222
</div>
<div class="box3">
3333
</div>
<div class="clear"></div>
</div>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异