无法添加CSS背景图片

时间:2020-02-05 01:38:00

标签: javascript html css bootstrap-4

enter image description here [1]

我正在使用引导程序来创建主页。 但是,由于某种原因,我无法添加背景图片。 我尝试添加CSS正文,添加html ... etc 它只是没有改变我的网站上的任何内容。

body {
  line-height: 1.7;
  color: gray;
  font-weight: 300;
  font-family: "Work Sans", sans-serif; 
  background-image: url("/images/slider_3.jpg")!important;
}

::-moz-selection {
  background: #000;
  color: #fff; }

::selection {
  background: #000;
  color: #fff; }
.btn
{

  width: 21%;
 height:250px;
  border: none;
  background-color:  #70B1D1;

  padding: 14px 28px;
  font-size: 40px;
  cursor: pointer;
  text-align: center; 

}

.btn:hover {
  background-color: #f7f5ed;
}
a {
  -webkit-transition: .3s all ease;
  -o-transition: .3s all ease;
  transition: .3s all ease; }
  a:hover {
    text-decoration: none; }

.text-black {
  color: #000 !important; }

.text-white {
  color: #fff !important; }

/* Navbar */
/* Blocks */
.site-section {
  padding: 7rem 0; }


这是我的CSS的一部分。

2 个答案:

答案 0 :(得分:0)

也许您的背景图片被覆盖了。您可以使用important选项使其正常工作

答案 1 :(得分:0)

您必须指定如下路径:

background-image: url("../../images/slider_3.jpg");

或者如果您的images文件夹位于根目录,则可以尝试:

background-image: url("/images/slider_3.jpg");