2017-09-01 65 views
-1

我剛開始使用laravel進行一個項目,並且想爲我的主頁創建一個完整的背景圖像。我嘗試了正常的css html方法,但它不起作用。這裏是我的代碼 home.blade.php:我想從Laravel項目的刀片中放入背景圖像

<html> 
<head> 
    <title> AgroHelp Login</title> 
    <link href="{{asset('css/home.css')}}" rel="stylesheet" /> 
</head> 
<body> 
<div class='view_parent_image1'> 

    </div> 
<p style ="text-align:center;">This is full screen</p> 


</body> 

,這是home.css

.view_parent_image1{ 
    background-image: url('../resources/Image/JD.jpg'); 
    background-size: cover; 
} 

我的形象是在資源/圖像/ JD.jpg; 和home.css在public/css/home.css中;

+0

你需要給圖像 –

+1

的完整路徑添加一些內容view_parent_image1格... – veera

+0

Itried的完整路徑,但仍無法正常工作。我試圖在div中添加一些內容,但仍然沒有工作。 –

回答

0

在Laravel,你的CSS文件無法訪問/資源目錄。

您應該將此圖片從資源移動到公共目錄。看看Laravel Mix - Copyin Files來管理你的項目的公共資產。

我認爲應該爲你工作。

0

嘗試一些這樣的事

body { 
    background-image: url('../resources/Image/JD.jpg'); 
    background-size: cover; 
} 
0

地方你的形象進入公衆/上傳路徑,並使用該

.view_parent_image1{ 
    position: fixed; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background: url({{ URL::asset('uploads/background_image.png') }}) no-repeat center center fixed; 
    background-size: cover; 
} 
+0

這沒有工作 –