【问题标题】:Laravel 8.x - Not able to add a button in laravel component fileLaravel 8.x - 无法在 laravel 组件文件中添加按钮
【发布时间】:2022-01-27 07:53:18
【问题描述】:

我正在学习 Laravel 刀片。我已经安装了微风,我正在尝试在 dashboard.blade.php 中添加一个按钮。

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Dashboard') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6 bg-white border-b border-gray-200">
                    Hello, You're logged in!
                    <br><br><button type="button" class="btn btn-danger">Danger</button>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>

按钮显示时没有任何形状或轮廓。你能告诉我我在这里犯了什么错误吗?

【问题讨论】:

  • tailwind 中没有 .btn.btn-danger 类。如果你想使用它,你应该看看 tailwind 文档:tailwindcss.com/docs/utility-first
  • 在顺风中,您可以将类似的东西用于类似的危险按钮:rounded-md bg-red-500 text-white focus:ring-red-600 px-4 py-2 text-sm 作为按钮类。我没有测试它,但它应该看起来不错
  • 谢谢,我认为使用 bootstrap 比使用顺风功能更好
  • 是的,但是看看这些类,您已经在使用 tailwind:max-w-7xl mx-auto sm:px-6 lg:px-8。同时使用 Tailwind 和 Bootstrap 会很麻烦,它们只会互相取消

标签: laravel tailwind-css laravel-breeze


【解决方案1】:

查看您的标记,有一些 Tailwind 相关的类,所以我假设您使用的是 Tailwindcss。

在这种情况下,您尝试在 Tailwind CSS 设置中使用 Bootstrap 类。

为了实现与危险按钮类似的按钮,您可以这样做:

<button 
    type="button" 
    class="rounded-md bg-red-500 text-white focus:ring-red-600 px-4 py-2 text-sm">Danger</button>

https://tailwindcss.com/docs/installation

【讨论】:

    猜你喜欢
    • 2021-05-11
    • 2021-05-02
    • 2021-11-27
    • 2021-04-17
    • 2021-06-12
    • 2019-09-12
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    相关资源
    最近更新 更多