【问题标题】:tailwind certain custom color not taking effect in laravel 8 welcome page顺风某些自定义颜色在laravel 8欢迎页面中未生效
【发布时间】:2021-03-20 04:14:24
【问题描述】:

我正在尝试向 tailwind.config.js 添加自定义颜色并将其用作背景或文本颜色,但它没有生效。奇怪的是我之前在顺风配置中添加了其他自定义颜色,这些都可以正常工作,只有我尝试添加的任何新颜色都不起作用。 这是我的tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme');

module.exports = {

theme: {
   extend: {
        colors:{
            salmon: {
                th1: '#B03060',    
            },
            tuna: {
                th1: '#393B3E',    
            },
            wildblueyonder: {
                th1: '#768DAE',
            },
            xanadu: {
                th1: '#798578',
            },
            napa: {
                th1: '#AC9F8F',
            },    
            cararra: {
                th1: '#F6F7F4',    
            },
            kimberly: {
                th2: '#7A81A8',
            },
            shakespeare: {
                th2: '#53A7CE',
            },
            jordyblue: {
                th2: '#8CCBF3',
            },
            softpeach: {
                th2: '#FAF7F6',
            },
            softr: {
                th2: '#FAF7F6',    
            },
        },
        fontFamily: {
            sans: ['Nunito', ...defaultTheme.fontFamily.sans],
        },
    },
},
variants: {
    extend: {
        opacity: ['disabled'],
    },
},

plugins: [require('@tailwindcss/forms')],
};

这是我的视图刀片文件代码,其中我使用 color(text-salmon-th1) 作为登录 a href 标记中的文本。

 <div class="flex lg:justify-center">
                <label class="bg-tuna-th1">test</label>
                <a href="{{ route('login') }}"
                    class="inline-flex px-6 py-2 text-2xl font-semibold text-salmon-th1 transition duration-500 ease-in-out transform rounded-lg hover:bg-red-700 hover:to-red focus:shadow-outline focus:outline-none focus:ring-2 ring-offset-current ring-offset-2">@lang("Login")</a>
                <a href="{{ route('register') }}"
                    class="inline-flex items-center text-2xl px-6 py-2 ml-4 font-semibold text-white transition duration-500 ease-in-out transform bg-red-800 rounded-lg shadow-xl hover:to-red hover:bg-red-700 hover:text-white focus:shadow-outline focus:outline-none focus:ring-2 ring-offset-current ring-offset-2">@lang("Register")</a>
            </div>

我试过清除浏览器缓存,清除 laravel 视图缓存。 每次我更改 tailwind 配置文件中的某些内容时,我都会尝试“npm run watch”或“npm run dev”。 而且我知道 tailwindcss 包含在页面中,因为其他颜色的金枪鱼、wildblueyonder 等仅适用于我添加的新颜色,包括“鲑鱼”不起作用。

我已经筋疲力尽地寻找原因......任何帮助将不胜感激。

【问题讨论】:

    标签: css laravel-8 tailwind-css


    【解决方案1】:

    好吧,我觉得自己很愚蠢,但我明白了为什么它不起作用。这是因为公用文件夹比当前框架文件夹高出一级。当我运行“npm run dev”时,它在错误文件夹中创建了带有 app.css 文件的公共文件夹。

    要解决这个问题,我必须更改 webpack.mix.js 中的代码并添加以下行。

    我的路

    /public_folder_name/
    /framework_folder_name/
    

    将此行添加到 webpack.mix.js 文件中

     mix.setPublicPath('../public_folder_name/');
    

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 2021-09-08
      • 1970-01-01
      • 2014-01-29
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      相关资源
      最近更新 更多