Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lukeboy_2002's avatar

Gradient Background image from 100% to 1%

I have a vue app with laravel. This is my layout that I'm using on every page.

now I want to have a background image start 100 visible and at the bottom 0.

My background is located in my folder storage/public/assets/background.jpg.

How to do this in vue 3 with inertia, Laravel and tailwind 4.1?

0 likes
2 replies
LaryAI's avatar
Level 58

To achieve a gradient effect on a background image where it starts fully visible at the top and fades to transparent at the bottom, you can use CSS with Tailwind CSS utilities. Here's how you can do it:

  1. Add the Background Image: Use Tailwind's bg-cover and bg-center utilities to ensure the image covers the entire area and is centered.

  2. Apply a Gradient Overlay: Use a linear gradient to create the fade effect from 100% opacity to 0% opacity.

Here's an example of how you can implement this in your Vue component:

Explanation:

  • Background Image: The style="background-image: url('/storage/assets/background.jpg');" sets the background image for the div.

  • Gradient Overlay: The bg-gradient-to-b from-transparent to-black class creates a gradient that starts transparent at the top and becomes black at the bottom. You can adjust the colors as needed.

  • Absolute Positioning: The absolute inset-0 class ensures the gradient overlay covers the entire div.

This setup will give you a background image that starts fully visible at the top and fades out towards the bottom. Adjust the gradient colors and opacity as needed to fit your design requirements.

Please or to participate in this conversation.