我試圖製作一個交互式漢堡包圖標,並在代碼筆上找到了一個教程和代碼。問題是我在代碼筆上找到的代碼在我的機器上不起作用,但它在代碼筆上生成結果。另外,在CSS中,我可以看到放置在其他屬性中的某些屬性,這些屬性我都不明白。請參閱下面的代碼。將CSS屬性包含在另一箇中,以及在css中的'&'的含義
HTML:
<div class="nav-icon cross">
<div class="span"></div>
</div>
CSS:
.nav-icon{
height:70px;
width:88px;
position:relative;
.span {
height:6px;
width:55px;
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
background:black;
transition:all 0.3s;
&::before,&::after {
height:6px;
width:100%;
background:black;
position:absolute;
content:"";
transition:all 0.3s;
}
&::after {
top:20px;
}
&::before {
top:-20px;
}
}
&.active .span::after {
top:0;
transform:rotate(45deg);
}
&.active .span::before {
top:0;
transform:rotate(-45deg);
}
&.active .span{
background:none;
}
}
那不是CSS,它的SASS/SCSS,需要一個編譯器,使這些規則轉化爲CSS – LGSon
這是我們寫scss的方式。這裏是http://sass-lang.com/ –
的鏈接,這不是CSS。 '.span {&:: before {'在CSS中被翻譯爲'.span :: before {'。 –