SASS第十一篇 继承

2020-10-28 16:03:30 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		    /*继承是通过并集选择器, 不会拷贝只会保留一份*/
		  /* .center
		   {
		   		position: 50%;
		   		left: 50%;
		   		top: 50%;
		   		transform: translate(-50%,-50%);
		   }
		   .father
		   {
		   	@extends .center;
		   	 width: 300px;
			  height: 300px;
			  background: red;
			  .son
			  {
			  	@extends .center;
			  	 width: 200px;
			    height: 200px;
			    background: blue;
			  }
		   }*/
		   .center, .father .son, .father {
  position: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.father {
  width: 300px;
  height: 300px;
  background: red;
}
.father .son {
  width: 200px;
  height: 200px;
  background: blue;
}
	</style>
</head>
<body>
	<div class="father">
    <div class="son"></div>
</div>
</body>
</html>

0 人点赞