简体   繁体   English

CSS styles 对于<x->标签</x->

[英]CSS styles for <x-> tags

I need help with setting color to html divs.我需要帮助将颜色设置为 html div。 I use Laravel 8 and of course I installed simple auth module Breeze with tailwind css framework.我使用 Laravel 8,当然我安装了简单的身份验证模块 Breeze 和 tailwind css 框架。 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.如您所见,我在我的访客刀片中使用 $slot 变量来使用“x-”标签注入登录页面内容。 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.我尝试在标签中使用 'class="lol" style="background-color: white;"' 来设置它,但没有成功。

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.我在浏览器中使用了检查元素 function,我发现用作主要元素的“min-h-screen”class。 Well, now I can set color to this class using internal CSS style.好吧,现在我可以使用内部 CSS 样式为这个 class 设置颜色。 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. Ps 最重要的是在guest Blade 模板中插入此代码,以便将styles 应用于$slot 变量中的内容。

The recommendation is: in your laravel application go to \resources\views\vendor\jetstream\components\authentication-card.blade建议是:在你的laravel申请go到\resources\views\vendor\jetstream\components\authentication-card.blade

Took me a whole year to figure it out我花了整整一年才弄明白

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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