【发布时间】:2020-09-15 17:34:33
【问题描述】:
.menu {
position: fixed;
top: 0;
bottom: 0;
left: 0;
transform: translateX
(-100%);
transition: tranlation: all ease
0.25s;
&.open {
transform: translateX (0);
}
}
js文件:
$(document).ready (function (){
${".navbar-toggler"}.on("click", function (){
$("menu").toggleClass ("open");
});
});
&.open 没有在我的代码中被选中,并且在我的文本编辑器(VS 代码)中带有红色下划线,但讲师实现了相同的代码。请问在 CSS 中使用“&”有什么理由吗?
【问题讨论】:
-
这看起来更像是less或scss,将
.open移到父级下方并使用.menu.open。 -
请注意,
transition: tranlation: all ease 0.25s;{末尾有一个{ -
哦,原来如此。这是我在这里输入代码时的一个错误,但实际上并不是我在文本上实现的代码
标签: html jquery css bootstrap-4