pink老师课程-五彩导航栏+css权重叠加

对应b站课程——五彩导航栏,顺便扒了一下必应的icon

image-20220123141848000

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>导航栏</title>
	<link href="https://cn.bing.com/sa/simg/favicon-2x.ico" rel="shortcut icon">
	<link rel="stylesheet" type="text/css" href="css/linshi.css">
</head>
<body>
<div class="nav">
	<a href="#">恭</a>
	<a href="#">喜</a>
	<a href="#">发</a>
	<a href="#">大</a>
	<a href="#">财</a>
</div>
</body>
</html>

image-20220123140942093

image-20220123141950647

*{
	margin: 0;
	padding: 0;
}
/*链接属于行内元素,但在需要长宽的情况下,需要模式转换
文字需要垂直和水平居中
链接设置相同的背景图片
鼠标经过背景图片的时候,图片变换-为类选择器
*/
.nav a{
	color: black;
	font-weight: bold;
	display: inline-block;
	width: 200px;
	height: 200px;
	text-align: center;
	line-height: 180px;
	text-decoration: none;
	background: url(../images/灯笼.png) no-repeat;
}
.nav a:hover{
	background: url(../images/灯笼2.png) no-repeat;
}

优先级问题,权重计算

image-20220123145125034
1000
0100
0010
0001

.nav a{
	color: black;
}

/*第三个字变色*/
.nav .pink{
	color: pink;
}

image-20220123145138371

上一段权重为0010+0001

下一段权重为0010+0010

posted on 2022-01-23 14:23  cookie的笔记簿  阅读(127)  评论(0编辑  收藏  举报