tailwindcss/daisyui下拉组件无法更改颜色
我正在与TailWindCSS和Daisyui合作,以建立下拉菜单。代码在下面。
问题在于,当单击下拉菜单项(当它变得活跃时)时,即使我在< li&gt上使用了实用程序类
元素。单击时,如何自定义下拉菜单项的颜色?我真的更喜欢一种仅CSS的解决方案,因为我正在使用Tailwind和Daisyui的CDN版本(因此没有bg-white
,它也会变成紫色。 ;tailwind.config.js
可以修改。
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet" type="text/css" />
<div class="dropdown dropdown-hover">
<a class="mx-2 text-2xl">ABOUT</a>
<ul class="dropdown-content menu bg-blue-primary items-center">
<li class="bg-white"><a>Item 1</a></li>
<li class="bg-white"><a>Item 2</a></li>
</ul>
</div>
I'm working with TailwindCSS and daisyUI to build a dropdown menu. The code is below.
The problem is that when a dropdown menu item is clicked on (when it becomes active), it becomes purple, even though I'm using the utility class bg-white
on the <li>
element. How can I customize the color of the dropdown menu items on click? I'd really prefer a solution that is CSS-only, as I am using the CDN versions of Tailwind and daisyUI (and therefore have no tailwind.config.js
to modify.
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet" type="text/css" />
<div class="dropdown dropdown-hover">
<a class="mx-2 text-2xl">ABOUT</a>
<ul class="dropdown-content menu bg-blue-primary items-center">
<li class="bg-white"><a>Item 1</a></li>
<li class="bg-white"><a>Item 2</a></li>
</ul>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试将
Active添加到
正在更改BG颜色,但Daisyui覆盖了它。&lt; a&gt;
标签中,在无法更改配置的情况下,我所做的工作将在
&lt; style&gt;
block中添加。I tried adding
active:bg-white
to the<a>
tags that were changing bg color, but DaisyUI overrides it.Without being able to change the config, what I have done is added the style override in a
<style>
block.我将颜色更改为
pink-200
。I had changed the color to
pink-200
.