"TailwindCSS opts for the inclusion of prefexied utilities instead of relying

Trying to set the height of the div to h-2, with a class that includes height animation on medium devices.

The issue is that even though h-2 should be used on mobile, tailwindcss still uses h-20 instead.

Any thoughts on why this may be happening?

Here is the specific div causing the problem:

  <div className={`h-2 md:flex w-full text-white fixed bg-white mt-1 ${scrolling ? 'md:animationNav h-16' : 'md:animationBasisNav h-20'} dark:bg-gray-400`}></div>

https://i.sstatic.net/BzOew.png

Answer №1

The issue arises from the continued use of h-20 in tailwindcss on mobile devices instead of switching to h-2.

This problem occurs because you are applying the class h-20 (which sets the height to 20 across all screen sizes) rather than using md:h-20 (which sets the height to 20 only for screen size md and larger).

Furthermore, consider changing h-16 to md:h-16.

To address this issue, remember to add the md: prefix to classes that should apply solely to screen size md and above. This principle applies to other breakpoint prefixes as well. By default, all classes follow a mobile-first approach unless specified with a breakpoint prefix. For more information, refer to the Responsive Design section in the Tailwind CSS documentation.

Answer №2

My unique solution

Greetings, here's a suggestion for you to experiment with:


  <div className={`h-2 md:flex w-full text-white fixed bg-white mt-1 ${scrolling ? 'md:animationNav md:h-16' : 'md:animationBasisNav md:h-20'} dark:bg-gray-400`}></div>


You are now specifying that the height is 2 by default and 20 in medium devices.

Apply this approach across all your classes.

Step one: Specify the height for mobile devices

Step two: Include the classes for larger screens.

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

Having trouble with applying a custom class to React Bootstrap tabs?

When utilizing the react bootstrap tabs component, I encountered an issue with implementing a custom CSS style for the nav-link element within it using a customized parent class indicator. <Tabs defaultActiveKey="signup_renter" i ...

Guide on exporting a function from a class for easy import into another class

I am currently diving into TypeScript and React for spfx developments. Despite going through various tutorials, answers on Stack Overflow, and other sources, I am still struggling to fully grasp the concepts. Below is a snippet of my function within the E ...

I encountered a dilemma when trying to send a post request using Redux-Toolkit's RTK Query functionality

I've recently started learning RTK Query and I'm trying to send a post request to my backend. However, I'm encountering an issue where my backend is rejecting the data from my frontend with an error message stating that the name, email, and ...

Is it possible to use one table as a background and place another table on top of it?

Currently, I am designing an email template and due to restrictions, I can only use tables. I am looking for a solution to meet my requirements using tables. Since all the content is dynamically generated via an RSS feed, images cannot be used in this ca ...

Sequence of HTML elements arranged in a stack

Recently, I came across a useful jQuery tutorial called "jQuery for Absolute Beginners: Day 8". In this tutorial, there is an interesting code snippet that caught my attention: $(function() { $('.wrap').hover(function() { $(this).childre ...

Server functions are limited to accepting plain objects as arguments

Dealing with Next.js server action issue It seems that there is an error in the form: type Ingredient = { name: string; purchasePrice: Prisma.Decimal; } const onSubmit = async (values: Ingredient) => { await addIngredient(values) } ...

How do I switch back and forth between displaying content as 'none' and 'block' using JQUERY?

Take a look at this code snippet. <div class="sweet-overlay" tabindex="-1" style="opacity: 1;display: none;"></div> Is there a way to switch the style attribute value from none to block and back? ...

Solving Empty Array Element Issues (Using MongoDB, React, and Axios)

I'm currently developing an application that utilizes Axios to make a GET request to a server I've created. Below is the relevant snippet of the server code that might shed light on the issue: app.get("/getScheduledTimes/:day/:stationId", (req, ...

How can you add a new div directly after the parent div's content and display it in-line?

I have a banner that stretches to fill the width completely. Inside this main div, there is another smaller div measuring 30px in size positioned at the end. The nested div contains a close icon background image, and upon clicking it, the entire banner get ...

Having trouble getting the toggle menu to work using Jquery?

I am trying to create a toggle menu using jQuery on this particular page: . The menu is located in the top right corner and I want it to appear when someone clicks on the "Menu ☰" button, and then disappear when clicked again (similar to this website: ). ...

Tips for sending props when a button is clicked in React

I am currently working on a project where I have a list of Events that are fetched using axios.get and then mapped to an Event component. The Event component contains a button that, when clicked, opens up a Registration Component. My challenge is figuring ...

Overlapping Flexbox elements causing stacking issues

My attempt to create a gallery layout with two larger blocks amidst smaller blocks is not functioning correctly. The large block is overlapping the two smaller blocks below it. Is there a way to prevent block overlapping using CSS? I have searched Stack O ...

Tips for managing blur events to execute personalized logic within Formik

I am currently delving into the world of React/Next.js, Formik, and Yup. My goal is to make an API call to the database upon blurring out of an input field. This call will fetch some data, perform database-level validation, and populate the next input fiel ...

Typed NextJs navigation to a specific route

<Link href="/about"> <a>About Us</a> </Link> Is there a way to ensure type safety with NextJs links? Currently, it is challenging to restructure the Link component as it is just a string. I stumbled upon this repos ...

Vertical alignment is somewhat functioning but not completely

Could someone help me figure out why my green DIV is not vertically aligned in the middle of the red DIV and suggest a solution? Thank you! Link to JSFiddle .wrapper-alt { margin-right: auto; margin-left: auto; width: 980px; display:tab ...

Obtain the breakpoint value from Bootstrap 5

We have recently updated our project from Bootstrap 4 to Bootstrap 5. I am trying to retrieve the value of a breakpoint in my TypeScript/JavaScript code, which used to work in Bootstrap 4 with: window .getComputedStyle(document.documentElement) .g ...

Troubleshooting issue: Android deep linking is not functioning properly due to complications with the asset

I am currently working on incorporating deep linking into my Android app. Below is a snippet of code from my AndroidManifest file with the intent-filters: <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-per ...

Tips on how to stop a webpage from scrolling and instead allow only the inner content to scroll

Check out my plunker for reference. The goal I am aiming for is as follows: The webpage should stay fixed and not scroll in any direction If the content overflows its container, a scroll bar should appear strictly within that container I have a main co ...

How can you apply a class to a different element by hovering over one element?

Is there a way to darken the rest of the page when a user hovers over the menu bar on my website? I've been playing around with jQuery but can't seem to get it right. Any suggestions? I'm looking to add a class '.darken' to #conte ...

What is the best way to stack several elements on top of each other?

<div class="parent"> <div class="child" id="child-A"> <div class="child" id="child-B"> <div class="child" id="child-C"> </div> The main concept here ...