CSS(Cascading Style Sheets)是一种用于描述HTML或XML(包括SVG、MathML等各种XML方言)文档样式的样式表语言。通过CSS,可以控制网页的布局和外观,使得内容与表现分离,提高了网页的可维护性和可访问性。
style
属性定义样式。style
属性定义样式。<head>
部分使用<style>
标签定义样式。<head>
部分使用<style>
标签定义样式。<link>
标签引入。<link>
标签引入。!important
声明。!important
声明。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS分类筛选样式</title>
<style>
.container {
display: flex;
justify-content: space-around;
align-items: center;
height: 100vh;
}
.box {
width: 100px;
height: 100px;
background-color: blue;
color: white;
text-align: center;
line-height: 100px;
}
.red {
background-color: red;
}
.green {
background-color: green;
}
</style>
</head>
<body>
<div class="container">
<div class="box">Box 1</div>
<div class="box red">Box 2</div>
<div class="box green">Box 3</div>
</div>
</body>
</html>