Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I have installed bootsrap libraries to my laravel project. I have create a unique css under public folder public/css/custom.css. Then now i have this on the register_blade.php but when i clear cache still application does not show div card nor style. What am missing?

What I have tried:

PHP
//register_blade.php
<pre>@extends('layouts.app')

<head>
<link href="{{ asset('css/custom.css') }}" rel="stylesheet">

</head>
@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Register') }}</div>

                <div class="card-body">
                    <form method="POST" action="{{ route('register') }}">
                        @csrf

                        <div class="row mb-3">
                            <label for="name" class="col-md-4 col-form-label text-md-end">{{ __('Name') }}</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>

                                @error('name')
                                    
                                        {{ $message }}
                                    
                                @enderror
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="email" class="col-md-4 col-form-label text-md-end">{{ __('Email Address') }}</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">

                                @error('email')
                                    
                                        {{ $message }}
                                    
                                @enderror
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="password" class="col-md-4 col-form-label text-md-end">{{ __('Password') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">

                                @error('password')
                                    
                                        {{ $message }}
                                    
                                @enderror
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="password-confirm" class="col-md-4 col-form-label text-md-end">{{ __('Confirm Password') }}</label>

                            <div class="col-md-6">
                                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
                            </div>
                        </div>

                        <div class="row mb-0">
                            <div class="col-md-6 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Register') }}
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection



//custom.css
<pre lang="CSS">/* Custom styles for registration page */
.register-card {
  background-color: #f5f5f5;
  padding: 20px;
  border: 1px solid #ddd;
}

/* Custom styles for login page */
.login-card {
  background-color: #f5f5f5;
  padding: 20px;
  border: 1px solid #ddd;
}



JavaScript
//vite_config.js
<pre>import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/sass/app.scss',
                'resources/js/app.js',
            ],
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
    resolve: {
        alias: {
            vue: 'vue/dist/vue.esm-bundler.js',
        },
    },
});
Posted
Updated 15-Jul-23 2:50am

Did you open the web browser tools, go to the network tab and check that all files loaded correctly? There is an option to disable the cache. Check this box then reload the page. The browser caching catches many out.

Every browser has dev tools for debugging. You can learn more here: What are browser developer tools? - Learn web development | MDN[^] (note: Chrome ( also Edge, Opera, Brave, Vivaldi, etc..), FireFox, Safari each are slightly different but effectively have mostly the same tools.
 
Share this answer
 
Your link refers to the 'css' folder in your root which is wrong, it is public / then css / then custom.css -

HTML
<link href="{{ asset('/css/custom.css') }}" rel="stylesheet">


if you are making a call to the file from another page not in the root, use '../' to go back a folder -
HTML
<link href="{{ asset('../css/custom.css') }}" rel="stylesheet">


Tutorial is to be found at - HTML and CSS File Structure[^]

I noticed that you are making use of .scss files (SASS), note that you have to have Ruby installed for it to read and convert the styles properly to css but Ruby does not support newer files as of 2019, it will still read properly if within bounds prior to 2019, Dart Sass is now the standard - [Sass] For Beginners: The Friendliest Guide About INSTALLING and USING Sass on Windows[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900