为啥会报错呢

来源:4-2 sass案例(2)

慕函数4234673

2020-05-17 09:03:11

只要保存css文件就会报错

Error: Invalid CSS after "100%": expected expression (e.g. 1px, bold), was ";"

        on line 2 of C:\Users\Administrator\Desktop\sass案例\css\index.css

  Use --trace for backtrace.

[Finished in 1.3s]

index.html

<!DOCTYPE html>

<html>

<head>

<title></title>

<link rel="stylesheet" type="text/css" href="css/index.css">

    <meta charset="utf-8">

    <meta name="viewport" content="initial-scale=1.0,user-scalable=no,width=device-width">

</head>

<body>

<div class="header">

<div class="header-logo"></div>

</div>

</body>

</html>

scss

$src:"assets";

$bgcolor:red;

.header{

    width: 100%;

height: 45px;

background-color: $bgcolor;

display: flex;

justify-content: center;

align-items: center;

.header-logo{

        width: 100px;

        height:100%;

        background:{

        repeat:no-repeat;

        image:url("../"+$src+"/wap_logo@3x_581de69e.png");

        position: center;

        size: contain;


        }

}

}

css

.header {

  width: 100%;

  height: 45px;

  background-color: red;

  display: flex;

  justify-content: center;

  align-items: center; }

  .header .header-logo {

    width: 100px;

    height: 100%;

    background-repeat: no-repeat;

    background-image: url("../assets/wap_logo@3x_581de69e.png");

    background-position: center;

    background-size: contain; }


/*# sourceMappingURL=index.css.map */


写回答

1回答

好帮手慕星星

2020-05-17

同学你好,这边编译测试没有问题

http://img.mukewang.com/climg/5ec0b9ac0993f30108850891.jpg

同学的文件名称用的是.scss还是.sass呢。如果是.scss没有问题,如果是.sass就会报错哦,建议检查下。

祝学习愉快!

0

0 学习 · 10739 问题

查看课程