You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CSS报错:'property value expected'与'at-rule or selector expected'求助

CSS语法错误分析与修复:计算器样式报错解决

错误原因

  • 十六进制颜色值格式非法:你代码最后一行 .display .operator 里的颜色值 #66666 是5位长度,CSS规定十六进制颜色必须是3位(如#666)或6位(如#666666),5位属于无效值,直接触发「property value expected」报错。
  • 解析连锁异常:因为前面的无效颜色值打乱了CSS解析器的正常流程,导致后续检测出现误报「at-rule or selector expected」。

修复后的完整代码

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.app {
    display: flex;
    justify-content: center;
    height: 100vh;
    align-items: center;
}

.calculator{
    background-color: #22252D;
    width: 100%;
    max-width: 375px;
    min-height: 640px;
    display: flex;
    flex-direction: column;
    border-radius: 1.5rem;
    overflow: hidden;
}

.display{
    min-height: 200px;
    padding: 1.5rem;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    color: white;
    text-align: right;
    flex: 1 1 0%;
}

.display .input{
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.display .output{
    font-size: 3rem;
    font-weight: bold;
    width: 100%;
    max-width: 100%;
    overflow: auto;
}

.display .operator{
    color: #666; /* 修正为3位有效颜色值,也可替换为#666666 */
}

内容的提问来源于stack exchange,提问作者Seyaro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 21:37:17