The TailwindCSS breakpoints fail to trigger at specific breakpoints

Currently, I am in the process of working on a project using Next.js and Tailwind CSS with the goal of creating a responsive website.

One issue I am facing involves a specific component:

<div className="flex md:hidden">

The intention is for this div to initially display as flex, but then hide once it reaches a screen size of "md". However, it seems to be staying hidden regardless, and the flex property is never being applied as expected.

A similar problem occurs in another instance:

`<div className="bg-red-200 xs:bg-blue-500 sm:bg-pink-600 md:bg-green-400 lg:bg-gray-50"`

In this case, only the background color specified for the "md" screen size is being displayed across all screen sizes during testing.

I have attempted utilizing custom values, but unfortunately, this has not resolved the issue. Below is an excerpt from my tailwind.config.js file:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./app/**/*.{js,ts,jsx,tsx}",
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    screens: {
      'xs': '320px',
      'sm': '576px',
      'md': '960px',
      'lg': '1440px',
      'xl': '1280px',
      '2xl': '1536px',
    },
    extend: {},
  },
  plugins: [],
}

Despite extensively reviewing documentation, various StackOverflow inquiries, and watching numerous YouTube tutorials, I am still unable to pinpoint why this issue persists. Any assistance or insights you could provide would be greatly appreciated. Thank you.

Answer №1

The reason for this issue is due to the minimum display setting rather than the maximum. When using md, it affects both lg and md displays. I encountered the same problem and found a solution by utilizing max-md.

md:hidden

Change it to

max-md:hidden

By using max, it will only apply up to that specific display size.

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

Utilize Bootstrap4 to position content above the navigation icon

I need assistance to modify my code so that it will have the following appearance: I successfully created a navigation bar icon and inserted the logo, but I am struggling to position the data above the navigation icon: My current code: <nav class="n ...

In order to implement the functionality in JavaScript, the .slider::-webkit-slider

I need to create a slider that adjusts the size of the dot based on the value input. For example, when the value is 1, the dot size should be 10px and for a value of 100, it should be 100px. Is there a way to dynamically change the height of .slider::-web ...

Passing the title of a page as data to a component in Next.js

I am currently working on setting a custom title for each page within my next.js project. Here is an example of a simple Layout: const MainLayout = props => { return ( <Layout style={{ minHeight: "100vh" }}> <Head> < ...

Using Angular to scroll within a <div> that is obstructed by other <div>s and concealed by

I am currently in the process of developing a website using Angular. I have implemented a card feature that allows for text selection from a menu on the left side. The texts are displayed using the *ngIf directive. However, I encountered an issue where if ...

Placing an anchor around a div extends its clickable area beyond the div

Just starting out with programming and I'm running into a problem where the anchor is clickable outside of my div. The div includes a sliding tab from the right displaying a randomly generated film, and ideally the entire tab should be clickable to d ...

Are there any other default light colors in CSS aside from "gray"?

Seeking recommendations for background color combinations. The more suggestions, the better! Thank you :) ...

Is it possible to hover over an image that incorporates a gradient effect?

My website features various communication icons, including one for Instagram that I sourced from Font Awesome. I matched the color of this icon to the official Instagram logo using a Gradient effect. However, I am encountering an issue where the hover effe ...

Displaying and concealing table rows based on selected items

After spending a whole day trying to get this HTML/java script to work properly, I came across some code online that I used here. My goal is to have the "Colors*" row not displayed when the page loads, but to show the color options when a shirt size is sel ...

The CSS transition seems to be malfunctioning

I need help figuring out how to make the submenu in the navigation bar appear with a transition effect. The CSS code I'm currently using is: #navigation li ul { display: none; width: auto; position: absolute; margin: 0; padding: 0; ...

How can I retrieve the CSS style value within the C# code behind?

When working with ASP.NET code behind, I often find myself adding a css style to an element using the following command: elementID.Style.Add("padding", "20px"); However, once this css property is added to elementID, the question arises - how can I access ...

Basic media query does not affect div resizing or font changes in Chrome or Internet Explorer

I am facing an issue with a simple media query that is not working as expected in Chrome or IE, but strangely it works fine in FF. I have tried various formulations of the media query without success. Any assistance would be greatly appreciated. Below is ...

Is it possible to set a single Tailwind breakpoint that will automatically apply to all CSS styles below it?

Responsive design in Tailwind is achieved by using the following code snippet: <div className="sm: flex sm: flex-row sm: items-center"></div> It can be cumbersome to constantly include the sm: breakpoint for each CSS rule. I want ...

After running assets:install and assetic:dump, Font Awesome fonts are no longer functioning properly

Setting up a site on shared hosting has been going smoothly, except for the FontAwesome icons which Symfony is having trouble finding in their designated locations. The steps I followed to move the site to production on shared hosting are: To overcome th ...

Utilizing Bootstrap to set a dynamic background image that spans the entire width of a table

The background image on my About page is not displaying correctly. The first < div > in my container shows it as intended, but the second < div > has white bars on the sides of the table. As a newcomer to Bootstrap and HTML, I hesitated to see ...

I am experiencing issues with the background image not displaying correctly on Safari when accessing from my

I recently uploaded my simple website, but I encountered an issue when viewing it on my phone using the Safari browser. The background image at the top is not displaying properly. I attempted solutions from this and this, but unfortunately, none of them re ...

Warning: The `children` attribute returned a value of NaN

I am currently working on a tic tac toe web application. I encountered an issue when clicking the "Ver Ranking" button, as it displays a warning message that I'm unsure how to address: Warning: Received NaN for the `children` attribute. If this is exp ...

Align the content of a collapsed bootstrap row vertically

In a row, I have two columns, each containing their own row. When the page width hits the 'xs' break-point, the left column's row will stack its columns on top of each other. The right column is taller than the left column, which leaves a l ...

The HTML/CSS Progress Bar appears on the browser but does not appear when attempting to print the document

I am currently assisting a friend with creating a resume and we wanted to include a visually appealing progress bar for the skills section. After successfully implementing the progress bar and seeing it display correctly in the browser, we encountered an ...

Assign a background image to a master page utilized in subdirectories

In my website's root directory, I have a master page. Inside this root directory, there is a folder named Images which contains the background image for my master page. When I apply this master page to web pages located in the root directory, everythi ...

Glowing semi-opaque about spotify?

Recently, I decided to challenge myself by recreating the Spotify homepage using only pure Javascript and SCSS as a way to test my front-end development skills. You can view my progress so far at this link, although please note that it's still a work ...