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
- Laravel insert query not working
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- How to restore deleted records in laravel
- Laravel route parameter
- How to get last month records in Laravel
- How to display serial number in Laravel?
- Insert current date time in a column using Laravel
- If condition in foreach loop in laravel
- Get Array of IDs from Eloquent Collection
- Save or update pivot table data with additional column in Laravel
- Laravel order by date not working
- Add class to body in laravel view
- Laravel pagination links with query string
- How to return error message from controller to view in laravel
- Pagination in laravel
- How to pass data to multiple partial view files in laravel
- Ajax POST request in laravel
- Laravel 9 pagination with search filter
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- How to get specific columns using with method in laravel Eloquent relationship
- Redirect from www to non www in laravel using htaccess
- Delete all related comments on deleting a post in Laravel
- If no route matched route::fallback in laravel
- How to restore multiple records after soft-deletes in Laravel
- How to upload files to amazon s3 bucket using Laravel