2013-10-31 137 views
0

我有一个问题,它驱使我坚果。我开始学习RoR,我不知道为什么我无法在Bootstrap 3应用程序上设置背景图像。我尝试了一切,但图像不“加载”。Bootstrap背景图片3

我用这个网站做的:http://css-tricks.com/perfect-full-page-background-image/

可能是什么做错了什么?

**如果我将html更改为body,则没有任何反应。同样的事情,如果我删除引号或不。

在此先感谢!

更新:**对不起。 Newb错误。图像已损坏。有 问题。感谢所有帮助。

<!DOCTYPE html> 
    <html> 
     <head> 

    <title>Bootstrap 101 Template</title> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
     <!-- Bootstrap --> 
     <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> 

<style> 

html { 
     background: url('images/fondo.jpg') no-repeat center center fixed; 
     -webkit-background-size: cover; 
     -moz-background-size: cover; 
     -o-background-size: cover; 
     background-size: cover; 
    } 
    </style> 


</head> 
     <body> 



     <h1>Hello, world!</h1> 

     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
     <script src="https://code.jquery.com/jquery.js"></script> 
     <!-- Include all compiled plugins (below), or include individual files as needed --> 
     <script src="js/bootstrap.min.js"></script> 
     </body> 
    </html> 

有趣的是,如果我使用任何URL图像像voices.suntimes.com/wp-content/uploads/2013/08/...,一切工作正常。问题是与那些在我的电脑图像

+0

您是否在使用导轨? – Philip7899

+0

是@ philip7899,铁轨! –

+0

和我所有的图片都在app/assets/images目录中。 @ Philip7899 –

回答

1

尝试

background: url('images/fondo.jpg') no-repeat center center fixed; 

我认为行情会有所作为。

此外,您的第二个样式标记缺少结束斜线。它应该是:

</style> 

如果这些不工作,也尽量用

body { 
0

而且更换

html { 

,如果您使用的轨道,你要设置你的应用程序不正确。

在apps/assets/stylesheets目录中,应该放置样式表。您的图片应位于assets目录中的images文件夹中。然后您应该参考所有图像,如

background: url('/assets/fondo.jpg') no-repeat center center fixed; 

首先要弄好导轨可能会非常棘手。