无法使用Tailwind CSS向div添加背景图像

tf7tbtn2  于 2023-02-06  发布在  其他
关注(0)|答案(1)|浏览(152)

我尝试简单地添加一个背景图像,但我猜路径是错误的。我尝试改变路径,但没有一个工作。我错过了什么吗?
我的HTML:

<div class="w-1/3 flex flex-col p-2 bg-wave rounded-md m-2 mb-2">
    <!--some code here-->
</div>

我的tailwind.config.js文件:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './components/**/*.{html,js}',
    './pages/**/*.{html,js}',
    './index.html',
    './src/**/*.js',
  ],
  theme: {
    extend: { 
     backgroundImage:{
      'wave':"url:('..public/waves.png')"
     }
    },
  },
  plugins: [],
}

我的结构:

public
  output.css
  waves.png
index.html
tailwind.config.js
bqjvbblv

bqjvbblv1#

您应该将url:('..public/waves.png')更改为url:('/public/waves.png')

相关问题