【问题标题】:Detect hover inside div检测div内的悬停
【发布时间】:2019-04-27 08:28:37
【问题描述】:

我有一个包含child div 的parent div。当用户将鼠标悬停在parent div 上时,child div's 边框颜色和文本应变为白色。

我做了一个例子,带有No score, yet click and submit 文本颜色的框应该变成白色,边框颜色也应该变成白色。

<div class="flex w-full p-4">
    <div class="flex hover:bg-black hover:text-white text-black p-2 rounded cursor-pointer items-center w-full">
        <div class="w-1/2">
            <h4>???? RESTROOM</h4>
        </div>

        <div class="flex flex-wrap xs:w-full xs:mt-2 md:mt-0 w-1/2 py-4 border-black border-2 rounded relative">
            <span class="flex items-center text-black text-xs font-bold uppercase h-full pin-t absolute ml-2">
                No score yet, click and submit
            </span>
        </div>
    </div>
</div>
    
<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet"/>

我怎样才能检测到这一点? (我用TailwindCss)

【问题讨论】:

    标签: html css tailwind-css


    【解决方案1】:

    .flex:hover .text-black {
      color:#fff;
    }
    
    .flex:hover .border-black {
      border-color:#fff;
    }
    <div class="flex w-full p-4">
        <div class="flex hover:bg-black hover:text-white text-black p-2 rounded cursor-pointer items-center w-full">
            <div class="w-1/2">
                <h4>? RESTROOM</h4>
            </div>
    
            <div class="flex flex-wrap xs:w-full xs:mt-2 md:mt-0 w-1/2 py-4 border-black border-2 rounded relative a1">
                <span class="flex items-center text-black text-xs font-bold uppercase h-full pin-t absolute ml-2">
                    No score yet, click and submit
                </span>
            </div>
        </div>
    </div>
        
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet"/>

    【讨论】:

      猜你喜欢
      • 2017-05-17
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-14
      • 1970-01-01
      相关资源
      最近更新 更多