样式表分类:外部、内部、行内样式
文件结构:样式选择器和属性设置(属性值)
标签选择器:
<head>
<title>你好</title>
<style type="text/css">
p{
background-color: red;
font-size: 20px;
}
</style>
</head>
选择器:用来选择需要添加样式的位置
类选择器:
.p1{
}
<html>
<head>
<title>你好</title>
<style type="text/css">
body{
background-color: yellow;
background-image: url("概念图/2.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: top center;
}
</style>
</head>
<body>
<p>http</p>
<p>http</p>
</body>
</html>
外部样式:新建css文档再通过link插入到html代码中,使网页的表示层与结构层彻底分离
<html>
<head>
<title>你好</title>
<link rel="stylesheet" type="text/css" href="1.css">
</head>
<body>
<p>http</p>
<p>http</p>
</body>
</html>
颜色:
color:red;
color:#ff0000;
color:rgb(238,130,238);
text-indent:2em;首行缩进2字符
伪类通常设置在超级链接上
被激活:鼠标按下但还没松开
顺序必须按照上方规定
伪类包含两种:状态伪类和结构性伪类
元素指父元素,比如说body
伪元素选择元素中的部分,伪类选择整体元素
p::before{
content: "hahha";
}
*::selection{
background-color: red;
}*表示选中当前文档中的所有内容
CSS其他选择器
name可以重复,id不可以重复
<p id="name">http</p>
#name{
color: red;
}
class选择器要加. id选择器要加# 标签选择器直接写
p[class="p1"]{
color:red;
}
.div{
background-color: yellow!important;
}
<div class="div1 div3"></div> 以后面的div3的样式为准