有我的问题。我正在尝试在Gulp中将SASS编译为CSS,这是我得到的错误:
Message:
styles\main.sass
Error:
Invalid CSS after "* {": expected "}", was "{"
>> * { {
---^
这是Gulp遇到问题的SASS文件:
//resets
* {
margin: 0;
padding: 0;
user-select: none;
}
SASS不接受*选择器还是其他东西?
// EDIT
发布整个SASS文件:
//colors
$red: #ff6347;
//fonts
$font-stack: ‘Times New Roman’, Times, serif;
//resets
* {
margin: 0;
padding: 0;
user-select: none;
}
//placeholders
%upperAndLowerButtonsDivs {
display: inline-block;
cursor: pointer;
width: 150px;
padding: 6px 10px;
border: 2px solid white;
border-radius: 3px;
text-align: center;
font-size: 1.5rem;
margin: 10px;
letter-spacing: 0.1rem;
transition: all 0.35s linear;
}
html, body {
background-color: $red;
max-height: 100%;
max-width: 100%;
}
body {
position: absolute;
font-family: $font-stack;
font-size: 3em;
color: white;
width: 1000px;
height: 525px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
overflow-x: hidden;
}
#upperButtons {
text-align: center;
div {
@extend %upperAndLowerButtonsDivs;
&:hover {
color: $red;
background-color: white;
}
}
}
#timer {
text-align: center;
border: 2px solid white;
border-radius: 50%;
width: 276px;
height: 226px;
margin: 5% auto;
padding-top: 50px;
div {
display: inline-block;
cursor: pointer;
}
}
#lowerButtons {
text-align: center;
div {
@extend %upperAndLowerButtonsDivs;
&:hover {
color: $red;
background-color: white;
}
}
}
#mode {
display: block !important;
cursor: auto !important;
}
#time {
cursor: auto !important;
vertical-align: middle;
font-size: 1.5em;
}
#addTime, #reduceTime {
vertical-align: middle;
font-size: 0.6em;
}
#resume {
display: none !important;
}
@media only screen and(max-width: 590px) {
//placeholders
%upperAndLowerButtonsDivsMobile {
width: 80px;
line-height: 50px;
height: 50px;
padding: 3px 5px;
border: 2px solid #fff;
border-radius: 3px;
text-align: center;
vertical-align: middle;
font-size: 1.25rem;
margin: 0px;
letter-spacing: 0.1rem;
transition: all 0.35s linear;
margin-top: 25px;
}
#upperButtons {
margin-bottom: 40px !important;
div {
@extend %upperAndLowerButtonsDivsMobile;
}
}
#lowerButtons {
margin-top: 8px;
div {
@extend %upperAndLowerButtonsDivsMobile;
}
}
#timer {
margin-bottom: 0;
margin-top: 0 !important;
}
#longBreak {
line-height: 25px !important;
}
}
答案 0 :(得分:1)
如 this answer 中所述,SASS中的 Universal Selector (*
) 没有什么特别之处;它是一个完全有效的SASS选择器。
您的语法错误来自其他地方。
答案 1 :(得分:1)
它应该可以正常工作,检查你的代码,其他地方一定有错误。
答案 2 :(得分:0)