Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 背景图像未在jumbotron中显示_Css_Ruby On Rails_Ruby - Fatal编程技术网

Css 背景图像未在jumbotron中显示

Css 背景图像未在jumbotron中显示,css,ruby-on-rails,ruby,Css,Ruby On Rails,Ruby,我在Rails 3.2.21上运行Ruby 1.9.3。 我已将jumbotron类添加到idex.html.erb文件的顶部 <div class="jumbotron"> <h1>Handcrafted items from <br> around the world.</h1> <h2>Discover one-of-a-kind items</h2> </div> 文件jumbotron

我在Rails 3.2.21上运行Ruby 1.9.3。 我已将jumbotron类添加到idex.html.erb文件的顶部

<div class="jumbotron">
  <h1>Handcrafted items from <br>
    around the world.</h1>
  <h2>Discover one-of-a-kind items</h2>
</div>
文件
jumbotron.jpg
已按照说明保存到
app/assets/images
文件夹中。这对指导老师有效,他的jumbotron现在显示选定的背景图像,但我的没有。我的只是一个有文字的盒子,而图像却不在那里


我做错什么了吗?

您的
custom.css.scss
中的行是否可以:

.jumbotron {
    background-image: image-url("jumbotron.jpg");
}

Red关于使用资产管道在css文件中构建URL的更多信息:

好吧,我得到了要显示的背景图像,但这只是通过在
index.html.erb
文件中内联添加它

该代码现在是:


来自
全世界。 发现独一无二的项目


但是我无法更改字体。

我也只在的HTML代码中添加了内联的背景图像

 <div class="jumbotron" style="background-image:url('images/imageName.jpg'); background-position:right; background-repeat:no-repeat;">

将背景图像属性添加到任何CSS文件都不起作用(我将该文件和任何其他组合的“to”改为“to”)。我尝试了bootstrap.min.CSS、jumbotron-slower.CSS,创建我的onwn样式表并在任何其他CSS后调用它


没有其他东西对我有用!:-(

在你的CSS中输入此代码。设置“资产url”似乎可以做到这一点。希望这有帮助

.jumbotron {
  background-image: asset-url("name_of_image.PNG");
}

我也遇到了同样的问题,刚刚发现了一个解决方案。我在jumbotron中使用了一个div class=“container fluid”并将我的图像添加到其中。出于某种原因,只有内联样式似乎有效,所以我将所有样式都添加到了内联样式中

我的守则是这样写的:

<div class="container-fluid" style="background-image: 
    url('JumbotronPic.png');
    background-size: cover;
    min-height: 100vh;">blah blah blah </div>
废话废话

我试过了。同样的结果,图像仍然没有显示。css文件中生成了什么URL?服务器上的清单文件中该文件的URL是什么?部署到服务器时是否编译了资产?对不起,我对此很在行。这是我第一次使用RoR应用程序。我不明白你在问什么。文件如果这有帮助的话,请看这里:Steve Chesnowitz的答案应该是正确的。请注意,当使用
背景图像:资产url('your_image.png')
rails将跟踪路径直接到图像文件夹,因此无需编写完整路径。
.jumbotron {
  background-image: asset-url("name_of_image.PNG");
}
<div class="container-fluid" style="background-image: 
    url('JumbotronPic.png');
    background-size: cover;
    min-height: 100vh;">blah blah blah </div>