简体   繁体   中英

CSS styles for <x-> tags

I need help with setting color to html divs. I use Laravel 8 and of course I installed simple auth module Breeze with tailwind css framework. But now I need to change auth card color. All my views use blade template engine and this is my guest blade source:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    </head>
    <body>
        <div class="font-sans text-gray-900 antialiased">
            {{ $slot }}
        </div>
    </body>
</html>

And my login view source:

<x-guest-layout>
    <x-auth-card>
        <x-slot name="logo">
            <a href="/">
                <img class="header-logo-image" width="100" height="100" src="{{ asset('images/welcome_images/logo.svg') }}" alt="Logo">
            </a>
        </x-slot>

        <!-- Session Status -->
        <x-auth-session-status class="mb-4" :status="session('status')" />

        <!-- Validation Errors -->
        <x-auth-validation-errors class="mb-4" :errors="$errors" />

        <form method="POST" action="{{ route('login') }}">
          <!-- This is form for posting my request -->
        </form>
    </x-auth-card>
</x-guest-layout>

As you can see I use $slot variable in my guest blade to inject login page content using "x-" tags. But how can I change background color? I tried to set it using 'class="lol" style="background-color: white;"' in tag but it didn't work.

Solved. Of course I am going to explain it. The first thing is we need to find out what classes was used to construct containers in template. I used inspect element function in my browser, I found 'min-h-screen' class that is used as main. Well, now I can set color to this class using internal CSS style. And that worked.

<!-- Internal styles -->
<style type="text/css">
.min-h-screen {
    background-color: #1D2026;
  }

Ps The most important thing is to insert this code in guest blade template in order to apply styles to content in $slot variable.

The recommendation is: in your laravel application go to \resources\views\vendor\jetstream\components\authentication-card.blade

Took me a whole year to figure it out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM