What causes Tailwind Height to malfunction at breakpoints?

Recently, I integrated Tailwind CSS and Elements into my Laravel project.

While working on the responsive design aspect, I encountered an issue with the "height" property not functioning correctly when utilizing breakpoints such as "md:xxx".

Interestingly, other properties like background color, width, or flex are working as expected.

<div class="bg-pink-500 md:bg-black h-16 md:h-64"></div>

The only modification I made to Tailwind was adjusting my application's color palette.

I came across a suggestion that a missing file (postcss.config.js) might be causing this problem. Although I have postcss installed (v8.4.6), manually creating and filling the file with the following contents did not resolve the issue:

postcss.config.js

module.exports = {
plugins: [
  require('postcss-import'),
  require('tailwindcss'),
  require('autoprefixer'),
 ]
}

This is how I included the CSS links in my HTML:

HTML CSS links

<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">

{{-- Tailwind Components --}}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tw-elements/dist/css/index.min.css" />

webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
    require('autoprefixer'),
]);

mix.sass('resources/scss/style.scss', 'public/css');

tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme');

module.exports = {
purge: [
    './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
    './storage/framework/views/*.php',
    './resources/views/**/*.blade.php',
    './resources/**/*js'
],

theme: {
    extend: {
        fontFamily: {
            'montserrat': ['Montserrat'],
            sans: ['Montserrat'],
            serif: ['Montserrat'],
            mono: ['Montserrat'],
            display: ['Montserrat'],
            body: ['Montserrat']
        },
        colors: {
            'black1': '#181818',
            'black2': '#323232',
            'white0': '#F9F9F9',
            'white1': '#F1F1F1',
            'white2': '#E4E4E4',
            'red1': '#8E0000',
            'red2': '#BA0000',
            'red3': '#D62323'
          },
    },
},

variants: {
    extend: {
        opacity: ['disabled']
    },
},

plugins: [
    require('@tailwindcss/forms')
]

};

Thank you

UPDATE:

Even after setting breakpoints, the CSS continues to use default settings instead of the specified breakpoint styles.

Here is a screenshot showing the CSS in developer tools for reference

Answer №1

Upon reviewing the screenshot in the post, it is evident that the CSS file (index.min.css) sourced from Tailwind CDN overrides app.css. To resolve this issue, ensure that you prioritize calling Tailwind CDN first:

    {{-- Tailwind Components --}}
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tw-elements/dist/css/index.min.css" />

    <!-- Styles -->
    <link rel="stylesheet" href="{{ asset('css/style.css') }}">
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">

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

Design elements for React and Angular JS

Is there a way to design UI components in a style that is compatible with both Angular JS and React? These two technologies will be utilized simultaneously within the same application. ...

Permanent header that clicks into place below the primary fixed header

I've been collaborating with fellow developers on this platform to tackle a persistent issue related to a fixed header. Here is the updated fiddle for reference: http://jsfiddle.net/f95sW/ The Challenge 1) As you scroll down the page, the yellow bl ...

The Android WebView experiencing issues with the functionality of the Hamburger Menu

I'm facing an unusual issue with the Android WebView in my app. The hamburger menu on my website works perfectly fine on my mobile browser, but when I try to open it in the Android WebView, it does not fully expand to show the menu items. I have trie ...

Steps for creating a fixed menu bar that remains stationary while scrolling

I am facing three challenges: When I hover over my menu links, I want them to become 'bold', but it causes the items on the right to move slightly. How can I prevent this movement? In regard to the dropdown menu on "Two", how can I ensure t ...

Make sure to use the jQuery load function to specifically target and retrieve

Hello, I'm new to working with jQuery and I have a question about adding a vertical scrollbar to a jQuery modal window. Specifically, I want the scrollbar to appear when there is a large amount of text within the modal window. Can you guide me on wher ...

Showing a hidden div after an unsuccessful AJAX call

Encountering an issue with displaying a div notification using the code snippet below: $.ajax({ url: url, cache: false, async: false, success: function (data) { response = jQuery.parseJSON(data); }, error: functi ...

Troubleshooting the Div Ordering Problem in Bootstrap 4

Currently, I am using Bootstrap 4 and facing an issue with the layout order. Despite searching for a solution extensively, I have not been able to get it right or find one in the archives. Here is what I need... For desktop view, the layout should appear ...

Adjust the position of elements based on their individual size and current position

I am faced with a challenge regarding an element inside a DIV. Here is the current setup... <div id="parent"> <div id="child"></div> </div> Typically, in order to center the child within the parent while dynamically changing i ...

Implement a fadeout effect by using a timeout function that adds a class to the div element in

I implemented a loader on my webpage that animates for 3 seconds before a function kicks in to modify the styles and make it invisible. I am looking to add a fadeout effect when the 'waa' style is applied to the 'load' div. setTimeou ...

Understanding CSS and the implementation of media queries

Imagine having this scenario /* css for elements section #1 in page css for elements section #2 in page */ @media screen and (max-width: 960px) { /* redefines/alters CSS for elements in section #1 in page */ } @media screen and (max-width: 700px) { /* r ...

Mobile Device Centering Problem with Bootstrap Cards

Despite my thorough research efforts, I have been unable to find a solution. The code snippet below is meant to display the image provided, but it seems to shift to the left when viewed on a mobile device. If anyone can assist me with this issue, I would ...

JavaScript code for opening and closing buttons

I created a button that successfully opens, but I am struggling to figure out how to close it. Can someone assist me with this? Additionally, I have one more query: How can I remove the border when the button is clicked? document.getElementById("arrowb ...

Having trouble clicking the button due to the overlay blocking it?

This code contains the HTML portion <li id="nav1" class="navs"><a unselectable="on" draggable="false" class="Navigation" href="http://youtube.com">YouTube</a></li> Below is the CSS code .navs:after { content: ""; position: ab ...

I'm looking for a script similar to ckeditor that automatically removes any style and script elements when pasting code into a textarea field

Does anyone know of a script similar to ckeditor that can automatically remove CSS and scripts when text is pasted into a textarea? I would like to prevent any unwanted styling or scripting from being copied and pasted onto my website. ...

Having trouble incorporating transitions into the hover effect

Currently, I am working on a project using React and Tailwindcss. The issue I am facing involves creating a card with shadowed text that only appears when hovered over an image. I want to make the hover effect smoother by adding a transition class, but I a ...

Applying CSS to an iframe using JavaScript: A Step-by-Step

I have an Iframe editor and I am trying to change some CSS inside the editor. However, when I attempt to apply the CSS, it does not affect the styles within the Iframe. <div id="editor" style="flex: 1 1 0%;"> <iframe src="https://editor.unlay ...

What could be causing that unusual behavior within the quasar framework's select CSS?

I am facing an issue with a select control that needs to be aligned on the right side of the screen. Despite using HTML and CSS to achieve this, there is strange behavior when I initially click on the control. It breaks the options layout, but as I navigat ...

ensure text is aligned perfectly on image {CSS HTML}

How can I correctly position text on an image? I have three blocks of text that I want to align on the same line with the image, but I'm struggling with it :( #banner { justify-content: center; height: 600px; margin-to ...

Issue: Duplicate modules found in CKEditor 5 causing errors

Looking for assistance with integrating CKEditor 5 into a web application built with Vue.js and Laravel. To install the necessary dependencies, I used the following command: npm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic as ...

Move the element from the center of the screen back to its starting position

Looking to craft a single animation that will transition elements from the center of the current view back to their original positions. Unfortunately, CSS animations do not support toggling the display property. This limitation causes the second rectangle ...