【问题标题】:CSS giving error: "Expected selector for the style rule"CSS给出错误:“样式规则的预期选择器”
【发布时间】:2020-04-26 17:24:25
【问题描述】:

我正在使用 ASP.net Web 应用程序,使用以下 CSS 修改默认 CSS 时会报错:

样式规则的预期选择器

这似乎是一个 CSS 版本问题。我如何知道我使用的是哪个版本的 CSS?如何升级?

这是取自Codepen的CSS

$white: #fff;
$google-blue: #4285f4;
$button-active-blue: #1669F2;

.google-btn {
width: 184px;
height: 42px;
background-color: $google-blue;
border-radius: 2px;
box-shadow: 0 3px 4px 0 rgba(0,0,0,.25);
.google-icon-wrapper

{
position: absolute;
margin-top: 1px;
margin-left: 1px;
width: 40px;
height: 40px;
border-radius: 2px;
background-color: $white;
}

.google-icon {
position: absolute;
margin-top: 11px;
margin-left: 11px;
width: 18px;
height: 18px;
}

.btn-text {
float: right;
margin: 11px 11px 0 0;
color: $white;
font-size: 14px;
letter-spacing: 0.2px;
font-family: "Roboto";
}

&:hover {
box-shadow: 0 0 6px $google-blue;
}

&:active {
background: $button-active-blue;
}

}

@import url(https://fonts.googleapis.com/css?family=Roboto:500);

【问题讨论】:

  • 在 .google-icon-wrapper 之前缺少一个 }

标签: css css-selectors syntax-error


【解决方案1】:

您可以使用以下 css 语法转换您的语法

检查sn-p:

@import url(https://fonts.googleapis.com/css?family=Roboto:500);
.google-btn {
  width: 184px;
  height: 42px;
  background-color: #4285f4;
  border-radius: 2px;
  box-shadow: 0 3px 4px 0 rgba(0, 0, 0, 0.25);
}
.google-btn .google-icon-wrapper {
  position: absolute;
  margin-top: 1px;
  margin-left: 1px;
  width: 40px;
  height: 40px;
  border-radius: 2px;
  background-color: #fff;
}
.google-btn .google-icon {
  position: absolute;
  margin-top: 11px;
  margin-left: 11px;
  width: 18px;
  height: 18px;
}
.google-btn .btn-text {
  float: right;
  margin: 11px 11px 0 0;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.2px;
  font-family: "Roboto";
}
.google-btn:hover {
  box-shadow: 0 0 6px #4285f4;
}
.google-btn:active {
  background: #1669F2;
}
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
<div class="google-btn">
<div class="google-icon-wrapper">
<img class="google-icon" src="https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg" />
</div>
<p class="btn-text"><b>Sign in with google</b></p>
</div>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2022-01-13
  • 1970-01-01
  • 2018-11-20
  • 2019-07-14
  • 1970-01-01
  • 2022-12-11
  • 2019-05-15
  • 2010-12-31
相关资源
最近更新 更多