How to add background image to div using Tailwindcss, Vite in Laravel Environment
You can easily add background image to div using Tailwindcss, Vite in Laravel Environment. You have to first install Laravel and create a images directory in public directory and upload the image in images directory and use the below code snippet to add the background image.
Step 1 : First create the Laravel project.
Step 2 : Create the images directory in pubic directory and upload the image in it.
Step 3 : Create a view file and copy/paste below code in it.
Change the filename as per your requirment.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="antialiased">
<div class="p-[20px]" style="background-image: url('./images/banner.png')">
<p class="text-white font-bold"> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nam minima recusandae, exercitationem aut omnis labore libero itaque aperiam qui voluptate eos odio magnam dolorum alias accusantium porro et asperiores totam. </p>
</div>
<div class="p-[20px] bg-[url('./images/banner.png')]">
<p class="text-white font-bold"> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nam minima recusandae, exercitationem aut omnis labore libero itaque aperiam qui voluptate eos odio magnam dolorum alias accusantium porro et asperiores totam. </p>
</div>
</body>
</html>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Delete all related comments on deleting a post in Laravel
- How to validate URL with https using regex in laravel
- How to call controller function from view in Laravel
- After image selected get validation error in laravel
- Create a record if not exist in laravel
- How to create static page in Laravel
- Check if Relationship Method Exists in Laravel
- How to create and run user seeder in laravel
- How to get path from current URL in Laravel
- Redirect from www to non www in laravel using htaccess
- How to create event and listener in laravel ?
- How to pass variable from controller to model in Laravel
- Call to undefined relationship [user] on model [App\Models\Post]
- Extract only time from datetime in laravel
- How to get all posts which contains comments in laravel
- Permission denied error while creating storage link in Laravel
- How to pass link from controller to view in laravel on ajax call
- Get domain name in laravel
- Laravel 10 starter app using breeze on live server
- How to validate website url in laravel using validaiton
- Define variable and use in Laravel controller method
- Cannot end a section without first starting one
- Pass variable from blade to controller Laravel
- How to fetch single row data from database in laravel
- How to Run CRON Job on LIVE SERVER on Cpanel in Laravel Project