Bootstrap - 设置容器的背景

Jac*_*ack 3 html css twitter-bootstrap

因此,例如下面的图片我正在打字给每个类="容器"它是单独的背景颜色/图片.

<div id="p" class="container">
</div>
Run Code Online (Sandbox Code Playgroud)

样式表

p.container {
     background-image: url(img/this_is_top.png) repeat;
}
Run Code Online (Sandbox Code Playgroud)

由于某些原因改变问题我在为它设置背景图像*时遇到了麻烦.

在此输入图像描述

ada*_*aam 5

关于您目前的背景图片问题

background-image: url(img/this_is_top.png) repeat;
Run Code Online (Sandbox Code Playgroud)

这是错的.但是您正在考虑遵循以下语法的后台速记CSS属性:

#p.container {background:#ffffff url('img/this_is_top.png') no-repeat center center;}
Run Code Online (Sandbox Code Playgroud)

如果你在样式表中设置样式并且你的文件夹层次结构是通常的(/〜/>/img等)那么它应该是:

#p.container {
     background-image: #ffffff url('../img/this_is_top.png') repeat center center;
}
Run Code Online (Sandbox Code Playgroud)

注意url之前的双点告诉CSS查找img文件夹的级别