【发布时间】: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