繁体   English   中英

CSS背景图片网址在使用方括号时不起作用

[英]CSS background-image url does not work when using brackets

使用括号编辑器。 这里

我试图通过链接index.html的stylecss将图像插入到class = portrait div中,但不会插入。

其他教程使用此。

但是为什么它对我不起作用?

index.html

<html>
    <head>
        <title> My name's lEEGANG</title>
        <meta name="viewport" content="width=device-width, user-scalable=no">
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <div clas="portrait"></div>
        <div clas="profile">profile</div>
    </body>
</html>

style.css

body{
    margin: 0; 
}

body{
    background-color: #111;
    color: #999;

}
.portrait {
    background-image: url(images/profile.png);
    height: 200px;

}

请检查HTML代码中的拼写

clas =“ portrait”->应该是double s“ ss”

它应该是::

<div class="portrait"> </div>

如果div为空,还要在CSS中包含宽度

.portrait {
    background-image: url(images/profile.png);
    height: 200px;
    width: 200px;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM