CSS背景图像没有显示

use*_*544 0 css background-image

我是CSS的新手,当我尝试插入background-image它时,它不会显示出来.

HTML:

<div id="logo"></div>
Run Code Online (Sandbox Code Playgroud)

CSS:

#logo {
   background-image: url(../images/logo.png);
   background-repeat: no-repeat;
   width: 376px;
   height: 81px;
   margin-top: 28px;
   margin-left: 128px;
}
Run Code Online (Sandbox Code Playgroud)

Bon*_*nyT 6

您需要URL中路径周围的引号,以及高度和宽度后的分号

#logo {
    background-image: url("../images/logo.png");
    background-repeat: no-repeat;
    width: 376px;
    height: 81px;
    margin-top: 28px;
    margin-left: 128px;
}
Run Code Online (Sandbox Code Playgroud)

  • 网址周围的引号是可选的. (4认同)