tomasosho's avatar

eloquent and css

I am trying to input my image wallpaper link in my .css but it's not working

.timeline-cover{
	background: url("../storage/wallpapers/$user->image") no-repeat;
}
0 likes
5 replies
MichalOravec's avatar
Level 75

You can't use php variable inside .css files, you can do it with add element to your views

<style>
.timeline-cover{
    background: url("../storage/wallpapers/$user->image") no-repeat;
}
</style>

// other html code

Or with inline styles like

<div style="background: url("../storage/wallpapers/$user->image") no-repeat;"></div>

Or you can generate .css file with Laravel.

1 like
walidabou's avatar

put it as inline style.

<div style="background:url('.../$user->image')"></div>

You can't add php code to external css

1 like
Snapey's avatar

What has the question got to do with Eloquent?

Please or to participate in this conversation.