I attempted to implement the hover effect on a custom Tailwind CSS class I created, but unfortunately, it does not appear to be functioning as expected

For example:

.btn {bg-blue-500 text-2 text-orange-300}
.btn2 {bg-orange-500 text-2 text-blue-300}

Attempted Solution:

Edit: Apologies for the oversight in not including the code I was working with... it was late at night.

< button className="btn hover:btn2"/>   <---this does not work btn2 does not actually get applied as a hover

The btn class is displayed, but when hovering, the styling of btn2 does not appear.

If there's something obvious that I'm missing or if it's already mentioned in the documentation, please point me in the right direction.

I've searched extensively, but I keep going around in circles. I have multiple styles I want to change by applying them in different states, and it would be cumbersome if I had to create separate classes like .btn .btn2 btn2-hover btn-hover.

Is this related to variants? Or is it due to the way CSS is interpreted in a specific order? Could it be that I expect hover to be applied to all internal CSS when it doesn't actually work that way? Do I need to make some kind of exception? Iā€™m confused.

Answer ā„–1

The solution was right there in the documentation. If anyone else is facing this issue, it was due to placing declared styles under tailwind @components instead of tailwind @utilities.

@layer utilities{
.btn {bg-blue-500 text-2 text-orange-300}
.btn2 {bg-orange-500 text-2 text-blue-300}}

Once you organize your styles correctly, you can use the states as intended - like in the example below:

<button className="btn hover:btn2"/>

Now everything should be working smoothly!

Answer ā„–3

Hey there, it seems like you may have a setting issue with your index.css file. Please take a look at the code snippet below:

@tailwind base;
@tailwind components;
@tailwind utilities;

html, body, #root{
      width: 100%;
      height: 100%;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I eliminate or override the CSS property from a content delivery network (CDN)?

Currently, I am utilizing swiper.js through a CDN. However, there seems to be an issue in the swiper-bundle.min.css CDN file where the .swiper-button-next and .swiper-button-prev classes are set to top:50%; like so: .swiper-button-next, .swiper-button-prev ...

Find the height of the viewport using jQuery, subtracting (n) pixels

Apologies if the topic seems puzzling, I couldn't find a better way to explain it. I utilized jQuery to adjust the height of a div to match the size of the viewport. var slidevh = function() { var bheight = $(window).height(); $(".container" ...

Steps for including a header and footer with page numbers in an HTML page without disrupting the rest of the content when printing

When I print a page with a table that spans multiple pages, I want to ensure that my header and footer are included on every page. The code I've tried so far has treated the entire content as one continuous page. How can I achieve this? ...

Steps for setting up dart sass on Fedora 37

I'm facing difficulties while trying to install Dart Sass on my Fedora 37 system. Despite following the official instructions and watching several tutorials, I keep encountering an error. According to the official Sass website: You can install Sass ...

Drag and drop surprise: When items are dragged onto the screen, a magical box will appear. But watch as the box disappears when the item is dragged

I am a newcomer to knockout JavaScript and am currently utilizing Knockout drag and drop functionality in my project. Initially, I have two divisions - one is visible while the other has a display property set to none. During the drag enter function, I wan ...

Incorrect Pixel Width with Relative Positioning in Internet Explorer 11

I'm encountering a positioning problem that seems to be specific to Internet Explorer (11). I'm attempting to absolutely position a div tag in relation to another element. The problematic code snippet appears as follows: <div id="FacebookWra ...

Prisma: Incorrectly identifying existing items where the list contains any of the specified items

Within my Prisma model, I have a property designated to store a list of phone numbers in the format phones String[] @unique When making an API call with a model that may include one or more phone numbers, my goal is to locate any existing record where any ...

Experiencing difficulties with the alignment of Bootstrap columns

I'm encountering an issue with displaying 3 Bootstrap columns in the ContentArea. Even though I can locate them using Developer tools, they seem to be positioned at the bottom of the ContentArea, making them not visible. I've attempted adjusting ...

Ways to determine the current page I am viewing

I am working with a list of tabs and I need to track my current location every time I click on a specific tab. My MainCTRL controller, which is the parent of all tab controllers, needs to be aware of the active tab at any given moment. I attempted to use n ...

Having trouble defining the width of cards in Bootstrap 4 using precise percentage values

Take a look at this example. I believe I should be able to manually set the width of card elements using CSS. Despite my efforts, the width seems to be ignored and the final computed value is not what I expected. For instance, on larger screens, all 6 ca ...

Images will only be displayed if the optional html parameter is included; otherwise, they will be hidden

In my parent component, there is an image displayed at a specific path (note: the image is already stored in my project). This path can optionally have additional parameters. If the For instance, The image is visible (image) when the HTML path is: ww ...

Unlocking the secrets: accessing environment variables from a Docker image within a NextJS application

After setting an environment variable in a Dockerfile, I expected to access this value within my application running inside the docker image (a nextJS application). The docker image creation process looks like this: FROM node:20.0.0-alpine3.17 RUN apk add ...

The :empty selector is failing to function properly in @media print queries

Currently, I am working in Twig on Symphony and have encountered an issue with an empty div that needs to be hidden in print mode. <div class="form-fields__list"> </div> Surprisingly, the :empty selector works perfectly fine on the screen, bu ...

Challenges with aligning Fontawesome stacks

I utilized the code example from Fontawesome's website to create a pair of stacked social media buttons and enclosed it in a div element to float them to the right side of the page. <div class="social-icons"> <span class="fa-stack fa-lg"> ...

Is there a way to modify the CSS or add custom styling within an iframe form?

Currently I am working on the following page: , where an embedded javascript form called infusionsoft (iframe form) needs to be made responsive at the request of my client. I'm wondering if there is a way to override the css or inject custom styles i ...

The Zurb Foundation has a multitude of redundant CSS entries

I have been utilizing Zurb Foundation for a while now, with a bower + compass setup as outlined in the documentation here. Recently, I encountered an issue where a specific page was loading slowly. Upon investigating, I discovered that there were numerous ...

What is the best way to implement useRouter in Next.js version 14?

When I utilize router = useRouter() and then try to redirect with router.push('auth/new-password') from the path 'auth/login/approve', I unexpectedly end up being routed to 'auth/login/auth/new-password'. Can someone explain t ...

Arranging Images with CSS Overlapping

I am striving to make the blue block and red block scale proportionally with the webpage, while also maintaining their position without any shifting up or down. As depicted in this gif, the blocks somewhat accomplish what I desire when scaling diagonally, ...

Utilize data retrieved from an API to customize the appearance of buttons through the combination of React and Sass styling techniques

I retrieved data from an API and used it to create a list of buttons. The data I received includes names and color codes. { name: "bob", colorCode: "#DC7472" }, { name: "ben", colorCode: "#69DCD1" }, { name: &q ...

Delving into the concept of the last-child element

Looking for assistance with selecting the final EC_MyICHP_Item from an HTML structure: <div class="decorator"> <div class="EC_MyICHP_Item"> <div class="text"> <h3><a target="_blank" title="" href="#">& ...