为什么我引入这个:root不起作用?
来源:2-1 汉克狗头部轮廓和耳朵
精慕门1783232
2019-01-22 18:47:53
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cartoon Dog</title>
<link rel="stylesheet" type="text/css" href="css/dog.css">
</head>
<body>
<div class="dog">
<div class="forehead"></div>
<div class="face"></div>
<div class="chin"></div>
<div class="ear"></div>
<div class="ear right"></div>
</div>
<style type="text/css">
:root{
--h1: #1b2f90;
--bg: #f9f9f6;
}
body{
background: #ffc400;
}
.dog{
width: 300px;
height: 400px;
position: relative;
}
.forehead{
width: 102px;
height: 48px;
background: --var(--bg);
position: absolute;
left: 50%;
transform: translate(-50%,0);
border-radius: 51px / 40px 40px 8px 8px;
}
.face{
}
.chin{
}
</style>
</body>
</html>
1回答
你好,可以参考下图修改:

祝学习愉快!
相似问题