p {
font: 10px/8px; // 纯 CSS,不是除法运算
$width: 1000px;
width: $width/2; // 使用了变量,是除法运算
width: round(1.5px)/2; // 使用了函数,是除法运算
height: (500px/2); // 使用了圆括号,是除法运算
margin-left: 5px + 8px/2px; // 使用了加(+)号,是除法运算
padding-left: + 100px / 2;
}
// 编译后
p {
font: 10px/8px;
width: 500px;
width: 1px;
height: 250px;
margin-left: 9px;
padding-left: 50px;
}
$font-size: 12px;
$line-height: 30px;
font: #{$font-size}/#{$line-height};
// 编译为
font: 12px/30px;
p {
color: #001100 + #040506;
}
p {
color: #010 + #040506; // #010 = #001100
}
// 编译后
p {
color: #041606;
}
p {
color: #041606;
}
p {
color: rgba(255, 0, 0, 0.75) + rgba(0, 255, 0, 0.75);
}
// 编译后
p {
color: rgba(255, 255, 0, 0.75);
}
<div className="demo-container">
<div className="popping-menu">
<input className="checkbox" id="checkbox" type="checkbox" />
<button>hello1</button>
<button>hello2</button>
<button>hello3</button>
<button>hello4</button>
<button>hello5</button>
<button>hello6</button>
<label className="label" htmlFor="checkbox">Click Me</label>
</div >
</div >
$d: 9em;
.demo-container {
height: 100vh;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
overflow: auto;
.popping-menu {
position: relative;
width: 10em;
height: 10em;
display: flex;
justify-content: center;
align-items: center;
button {
position: absolute;
display: block;
width: 4em;
height: 4em;
appearance: none;
background: #FFB66F;
border: none;
transition: all 0.3s ease-in-out;
opacity: 0;
border-radius: 50%;
color: white;
}
.checkbox {
display: none;
}
.checkbox:checked {
~ button {
$per: 30;
@for $i from 1 through 6 {
&:nth-of-type(#{$i}) {
$width: $i * 5.5em; // 每个按钮宽度是 4em 然后间距1.5em $i * 4em + $i * 1.5em => $i * 5.5em
opacity: 1;
transition-delay: 0.1s * $i; // 时间计算也是需要考虑上一个动画完成的时间
margin-left: $width;
}
}
}
~ .label {
transform: rotate(360deg) ;
}
}
.label {
z-index: 10;
border-radius: 50%;
background: #4791FF;
width: 6em;
height: 6em;
line-height: 6em;
text-align: center;
display: block;
color: white;
cursor: pointer;
user-select: none;
transition: all .9s ease-in-out;
}
}
}
@import "mathsass/dist/_math.scss";
$d: 9em;
button {
position: absolute;
display: block;
width: 4em;
height: 4em;
appearance: none;
background: #FFB66F;
border: none;
transition: all 0.3s ease-in-out;
transform: translate(0, 0) rotate(360deg);
opacity: 0;
border-radius: 50%;
color: white;
}
.checkbox {
display: none;
}
.checkbox:checked {
~ button {
// 以中间按钮为圆心画一个半径为 $d: 9em 的圆,然后将按钮一一排放在圆弧上
$per: 30;
@for $i from 1 through 6 {
&:nth-of-type(#{$i}) {
$angle: $per * ($i - 1) * 1deg + 180deg; // 加上180deg是因为在网页中 X轴的正方向是水平向右 Y轴的正方向是垂直向下
$x: cos($angle) * $d;
$y: sin($angle) * $d;
opacity: 1;
transition-delay: 0.1s * $i;
transform: translate($x, $y) rotate(360deg) ;
}
}
}
~ .label {
transform: rotate(360deg) ;
}
}