Breaking Points in Tailwind are crucial for creating responsive designs

I am attempting to create a simple div where I want px-5 for mobile screens and px-20 for larger screens. However, only px-5 is working and px-20 is not applying on large screens. Can someone help me understand why?

Code Output Image

 <div class="bg-white py-20  px-5  lg:px-20 ">
        <div class="w-full md:w-1/2 mx-auto space-y-8">
          <div class="bg-white py-20 rounded-xl shadow-lg p-6 flex flex-col items-center justify-between">
            <div class="flex flex-col md:flex-row items-center justify-between w-full">
              <div class="flex py-4 flex-col md:flex-row justify-start w-full h-full">
                <div class="flex flex-col lg:ml-10  md:items-start">
                  <h2 class="text-xl md:text-4xl font-semibold mb-2 text-center md:text-left">
                    Lorem ipsum dolor sit
                  </h2>
                  <p class="text-gray-600 text-center md:text-left">
                    Porem ipsum dolor sit amet, consectetur adipiscing elit.
                  </p>
                </div>
              </div>
              <div className="flex flex-col justify-center sm:justify-center lg:justify-end md:flex-row mt-4 md:mt-0 w-full ">
                <input
                  type="text"
                  placeholder="Enter email here"
                  className="lg:w-96 sm:w-1/2 py-2 px-2 sm:px-10 border border-gray-300 rounded-sm focus:outline-none focus:border-indigo-500 transition duration-150 ease-in-out"
                  // Adjust the width here, sm:w-1/2 means the input width will be half of the container on small screens and above
                />
                <button
                  className="mt-3  lg:w-1/3 sm:mt-0 flex items-center justify-center md:ml-4 text-white py-3 px-4 rounded-sm hover:bg-orange-700 focus:outline-none focus:bg-orange-700 transition duration-150 ease-in-out"
                  style={{ backgroundColor: "#F68219" }}
                  // Adjust the width here, sm:w-1/2 means the button width will be half of the container on small screens and above
                >
                  Start E-Filling Now
                  <img src="/arrow.svg" alt="" className="ml-2" />
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>

Expected Result Image

In the second image shown in the link, you can see that I want px-20 to apply on large screens as expected.

Answer №1

To create margins on both the left and right sides of the div, it is recommended to use the margin property instead of padding.

 <div class="bg-white py-20 mx-5 lg:mx-20">

Answer №2

<div className="bg-white py-20  px-5  lg:px-20 ">
  <div className="w-full  mx-auto space-y-8">
    <div className="bg-white py-20 rounded-xl shadow-lg p-6 flex flex-col items-center justify-between lg:mx-20">
      <div className="flex flex-col md:flex-row items-center justify-between w-full">
        <div className="flex py-4 flex-col md:flex-row justify-start w-full h-full">
          <div className="flex flex-col lg:ml-10  md:items-start">
            <h2 className="text-xl md:text-4xl font-semibold mb-2 text-center md:text-left">
              Lorem ipsum dolor sit
            </h2>
            <p className="text-gray-600 text-center md:text-left">
              Porem ipsum dolor sit amet, consectetur adipiscing elit.
            </p>
          </div>
        </div>
        <div className="flex flex-col justify-center sm:justify-center lg:justify-end md:flex-row mt-4 md:mt-0 w-full ">
          <input
            type="text"
            placeholder="Enter email here"
            className="lg:w-96 sm:w-1/2 py-2 px-2 sm:px-10 border border-gray-300 rounded-sm focus:outline-none focus:border-indigo-500 transition duration-150 ease-in-out"
            // Adjust the width here, sm:w-1/2 means the input width will be half of the container on small screens and above
          />
          <button
            className="mt-3  lg:w-1/3 sm:mt-0 flex items-center justify-center md:ml-4 text-white py-3 px-4 rounded-sm hover:bg-orange-700 focus:outline-none focus:bg-orange-700 transition duration-150 ease-in-out"
            style={{ backgroundColor: "#F68219" }}
            // Adjust the width here, sm:w-1/2 means the button width will be half of the container on small screens and above
          >
            Start E-Filling Now
            <img src="/arrow.svg" alt="" className="ml-2" />
          </button>
        </div>
      </div>
    </div>
  </div>
</div>

Inspect this closely because you were utilizing the tailwind utilities improperly in that specific div. To achieve the desired outcome, feel free to make adjustments to this code snippet.

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

Tips for effectively managing errors in Next.js getStaticProps

Currently, I am immersed in the development of my inaugural Next.JS application (Next and Strapi). All functionalities are operational, but I am interested in discovering the optimal approach to integrate error handling within getStaticProps. I have exper ...

Utilize Route Node components within your React application's interface to efficiently oversee and control Azure blobs

Hello everyone, As a newcomer to the world of React and Node, I am currently working on developing a React application for managing Azure blob storage. My journey led me to the Microsoft documentation which has proven to be extremely useful in this proces ...

What is the best way to determine the type of `rootReducer`?

My project is set up with a combination of React, Redux, Immutable.js, and TypeScript. As I worked on implementing it, I made an effort to declare types wherever possible which led me to discover an interesting issue. A code example illustrating the proble ...

Enhance the appearance of material-ui checkboxes with custom colors

Is it possible to modify the background color of an active checkbox with material-ui.com-framework? It seems like setting the style property does not impact the svg-color of the checkbox. <Checkbox label="Simple" style={st ...

Experimenting with a Node.JS server using my React front-end on my local machine

After successfully setting up my node.JS Express server to send JSON data from an API to the front-end, I deployed it on an AWS server. Now, I am focusing on developing the React front end of the project. However, when I try to make requests from localhost ...

Make the <textarea> occupy the entire available space

How can I make a <textarea> occupy all available space within a <td> element? Upon clicking inside the table cell, the <textarea> should display with precisely the same dimensions as the cell itself, resembling an Excel spreadsheet. I h ...

What is the best way to access extra User properties in the session callback and make them available to the user object?

Within the session callback of next-auth.js configuration, the user object contains standard properties like id, name, email, emailVerified, and image. I have added a new property to the User model in my schema.prisma file which is a relational property. M ...

A simple guide on integrating personalized color palettes into Material-UI Theme

One enhancement I'd like to make in my theme is the inclusion of a custom color called warn import React from 'react' import { MuiThemeProvider } from '@material-ui/core/styles' import createMuiTheme from '@material-ui/core/s ...

Ensuring the width of a div matches the adjacent containers

I need assistance in creating a form that adjusts its width based on the form fields. The form contains both explanatory text and input fields, each enclosed in a div with inline-block set. The outer div (also using inline-block) should not expand beyond ...

Adjusting the image placement within a modal window (using bootstrap 3)

Behold, an example modal: <!-- Large Modal --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

Updating the layout when transitioning between routes in Next.js 14 using the AppRouter design concept

I am a beginner in next.js and I want to create a navigation bar that can be shared between components using the approuter concept. I am currently working with next.js version "14.0.2". The folder structure mentioned below in the image https://i.stack.im ...

Troubleshooting a problem with a chat room feature in a

I am currently developing a chat application using node.js express and react. The app is functioning properly and able to send messages to all users, but I am facing an issue when trying to send a message to a specific room. The backend io.on('connect ...

Performing a simulated click on a dynamically inserted element using pure JavaScript

I am faced with the challenge of programmatically navigating a ReactJS-based website in a looped workflow. The process involves clicking on Element1, dynamically altering the web page to add Element2, then clicking on Element2, and so on until eventually r ...

CSS Hue Rotate is causing the image to appear darker

The CSS filter hue-rotate seems to be darkening my image according to my observations. For an example, visit: https://jsfiddle.net/m4xy3zrn/ Comparing images with and without the filter applied, it’s clear that the filtered one appears much darker than ...

I am looking to implement an animation that automatically scrolls to the bottom of a scrollable DIV when the page is loaded

My DIV is configured with overflow-y set to scroll. .scrolling-div { width: 85%; height: 200px; overflow-y: scroll; } If I have an abundance of content within this div, my goal is for it to automatically scroll to the bottom upon loading the page. I am ...

Apply CSS styles when the text exceeds the size of the textbox

Is there a way to create a textbox that scrolls on hover only if the text is longer than the textbox itself? Check out my attempt here: https://jsfiddle.net/SynapticError/wqh4ts3n/35/ The text should scroll on hover if it's longer than the textbox. ...

The 'setState' property is not found on the 'Window' type

I am encountering an issue with the code snippet in my index.tsx file let state = {}; window.setState = (changes: any) => { state = Object.assign({}, state, changes); ReactDOM.render(<App {...state} />, document.getElementById("root")); ...

Ways to eliminate the blue selection box when dragging canvas objects in fabric framework

I've been trying to find a solution to remove the annoying blue highlight box that appears when dragging on the canvas while using fabric js, but so far I haven't had any luck. I've tried the following code, but it only works for text and n ...

Upon the initial render, the fetch request in the NextJS Client component is not triggered

When I load my home page, I want to display a collection of cards from a client component. However, the API fetch request in the client component does not trigger on the initial render, preventing the cards from appearing. To fix this issue, I have to manu ...

Displaying the age figure in JSX code with a red and bold formatting

I have a webpage with a button labeled "Increase Age". Every time this button is clicked, the person's age increases. How can I ensure that once the age surpasses 10, it is displayed in bold text on a red background? This should be implemented below t ...