简体   繁体   English

当按钮悬停在顺风css中时如何更改笔触颜色

[英]How to change stroke color when button was hovered in tailwind css

I wanna ask something about how to change stroke color when button was hovered in tailwind, so I already made this code like this:我想问一些关于当按钮悬停在顺风时如何改变笔触颜色的问题,所以我已经编写了这样的代码:

<button class="w-[3.125rem] h-[3.125rem] flex items-center justify-center rounded-full border-2 border-[#969696] hover:border-0 hover:bg-white">
  <span>
    <svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M7 1L1 7L7 13" stroke="#969696" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
    </svg>
  </span>
</button>

okey, in above my code is working no giving error or some weird things, but the problem is I don't know how to change the stroke of my svg when my button is hovered, I already try to make some piece of code to styling my stroke to change the color, and the code is like this:好的,在上面我的代码没有给出错误或一些奇怪的事情,但问题是我不知道如何在我的按钮悬停时更改我的svg的笔划,我已经尝试制作一些代码来设置样式我的中风改变颜色,代码是这样的:

<svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path d="M1 1L7 7L1 13" stroke="#969696" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="hover:stroke-black" />
</svg>

everything is not okay in here, the problem is I must move my cursor on my svg to change the stroke but when I moving out my cursor from my svg only button change the background and my svg is not change the stroke, does anyone used to having problem like this?在这里一切都不好,问题是我必须将光标移到我的svg上以更改笔画,但是当我从我的svg仅按钮移出光标时,更改背景并且我的svg没有更改笔画,有没有人习惯有这样的问题? And how to solve this?以及如何解决这个问题? I hope someone can explain this, before that thank you, oh ya I will attach the screenshot about my problem, so that everyone who read this getting more understand about my problem 😁我希望有人能解释一下,在此之前谢谢你,哦,我将附上我的问题的截图,以便阅读本文的每个人都能更了解我的问题😁

在此处输入图像描述

在此处输入图像描述

The solution to this should be tailwinds group-hover state as discussed in How to make parent div activate styling of child div for hover and active对此的解决方案应该是顺风组悬停状态,如如何使父 div 激活子 div 的样式以进行悬停和活动中所述

Given that the solution could be something like this鉴于解决方案可能是这样的

<button class="group w-[3.125rem] h-[3.125rem] flex items-center justify-center rounded-full border-2 border-[#969696] hover:border-0 hover:bg-white">
  <span>
    <svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M1 1L7 7L1 13" stroke="#969696" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="group-hover:stroke-black" />
    </svg>
  </span>
</button>

Notice the group and group-hover .注意groupgroup-hover

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM