我想在Laravel项目的刀片中放置背景图像

问题描述 投票:-1回答:4

我刚刚开始使用laravel进行项目,我想为我的主页提供一个完整的背景图像。我尝试了正常的css html方法,但它无法正常工作。这是我的代码home.blade.php:

<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;
}

我的形象是资源/ Image / JD.jpg;和home.css在public / css / home.css中;

php html css laravel blade
4个回答
1
投票

在Laravel中,您的CSS文件无法访问/ resources目录。

您应该将此图像从资源移动到公共目录。看看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
投票

看一下这个:

.view_parent_image1{
   background: url('{{asset('uploads/'.$ourService->imageOne)}}');
   background-size: cover;
}

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.