如果可能,我想避免使用重复的代码。我现在所做的基本上是为#menu-icon
和#close-menu
使用类似的代码,唯一的区别是我在height:
属性中使用的百分比值。有没有使用SCSS避免使用重复代码的有效方法?
@import "../../resources/Variables.scss";
header {
position: fixed;
background-color: $color-background;
width: 100%;
height: 22%;
top: 0;
left: 0;
#menu-icon {
position: absolute;
height: 8%;
top: 45%;
left: 10%;
margin-right: -50%;
transform: translate(-50%,-50%);
cursor: pointer;
}
#close-menu {
position: absolute;
height: 15%;
top: 45%;
left: 10%;
margin-right: -50%;
transform: translate(-50%,-50%);
cursor: pointer;
}
}