<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>唯唯同学知识分享</title>
<!-- css使用方式
1.通过style标签设置样式
2.通过style属性设置样式
3.通过css文件使用
注意:css的特点
1.直接在style上写的内容优先级最高,同样的选择器,谁在后面谁的优先级比较高.
2.选择器的优先级,在其余情况下相同下,继承的样式<浏览器模式的样式<标签样式<class样式<id样式<style样式
3.可以使用在属性后面使用 !important 将属性优先级提升到最大.注:不要过度使用!important
4.越复杂具体的选择器,优先级越高
-->
<!-- 通过css文件使用 -->
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<!-- 通过style标签设置样式 -->
<style type="text/css">
#d1{
color: skyblue;
font-size: 50px;
}
.d1{
color: blue;
font-size: 50px;
}
div{
color: yellowgreen;/*添加在yellowgreen的后面!important*/
font-size: 50px;
}
#d2{
color: thistle;
font-size: 50px;
}
</style>
</head>
<body>
<div id="d1" class="d1">
helloworld 1
</div>
<!-- 通过style属性设置样式 -->
<div style="color: hotpink; font-size: 50px;">
helloworld 2
</div>
<div id="d2">helloworld 3</div>
</body>
</html>
初识css
最新推荐文章于 2022-12-03 21:45:14 发布