The content's div is not extending completely in the horizontal direction

Just starting out with tailwind CSS and struggling a bit with the design aspect due to my lack of CSS skills. Need some assistance troubleshooting my layout, particularly in making sure the div container stretches to fit the screen size properly.

The specific issue I'm facing is wanting the content within the div where the table resides to stretch up until the red line.

See below for the relevant code snippets:

<div className='min-h-screen bg-bgSecondary'>
            <Head>
                <title>{title}</title>
            </Head>

            {/* Top Navigation Header */}
            <Header />
            <Annoucement />

            {/* Body Content */}
            <div>
                {children}
            </div>
        </div>

Announcement.tsx

<div>
                <div className='flex w-full bg-yellow-400 shadow-bgTertiary shadow-sm px-4 py-4'>
                    <div className='flex flex-1 max-w-7xl mx-auto uppercase text-sm font-semibold text-gray-700 space-x-10 md:space-x-5 space-between items-center'>
                        <div className='flex-1'>
                            <p>Please refrain from <span className='underline font-bold'>sharing your password</span> to anyone.</p>
                        </div>
                        <div className='cursor-pointer' onClick={() => setShowAnnoucement(false)}>
                            <svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
                                <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>

index.tsx

<Layout>
      <div className='flex max-w-7xl mx-auto'>
        <div className='py-5 px-5 lg:px-3 2xl:px-0'>
          <div className='text-2xl uppercase font-bold'>
            <h1>Appointments</h1>
          </div>
          <div className='flex flex-col space-y-4 mt-3 outline-none'>
            <Tab.Group>
              <Tab.List className="flex space-x-3">
                <Tab as={Fragment}>
                  {({ selected }) => (
                    <button
                      className={
                        (selected ? 'bg-gray-500 text-white px-3 py-2 rounded-md font-bold' : 'bg-gray-700 px-3 py-2 rounded-md font-bold')
                      }
                    >
                      Approved
                    </button>
                  )}
                </Tab>
                <Tab as={Fragment}>
                  {({ selected }) => (
                    <button
                      className={
                        (selected ? 'bg-gray-500 text-white px-3 py-2 rounded-md font-bold' : 'bg-gray-700 px-3 py-2 rounded-md font-bold')
                      }
                    >
                      Waiting for approval
                    </button>
                  )}
                </Tab>
              </Tab.List>
              <Tab.Panels>
                <Tab.Panel>
                  <table className='border-collapse border border-slate-500 table-auto '>
                    <thead>
                      <tr>
                        <th className='border border-slate-600 p-3'>Song</th>
                        <th className='border border-slate-600 p-3'>Artist</th>
                        <th className='border border-slate-600 p-3'>Year</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr >
                        <td className='border border-slate-600 p-3'>The Sliding Mr. Bones (Next Stop, Pottersville)</td>
                        <td className='border border-slate-600 p-3'>Malcolm Lockyer</td>
                        <td className='border border-slate-600 p-3'>1961</td>
                      </tr>
                      <tr>
                        <td className='border border-slate-600 p-3'>Witchy Woman</td>
                        <td className='border border-slate-600 p-3'>The Eagles</td>
                        <td className='border border-slate-600 p-3'>1972</td>
                      </tr>
                      <tr>
                        <td className='border border-slate-600 p-3'>Shining Star</td>
                        <td className='border border-slate-600 p-3'>Earth, Wind, and Fire</td>
                        <td className='border border-slate-600 p-3'>1975</td>
                      </tr>
                    </tbody>
                  </table>
                </Tab.Panel>
                <Tab.Panel>Content 2</Tab.Panel>
              </Tab.Panels>
            </Tab.Group>
          </div>
        </div>
      </div>
    </Layout>

Answer №1

To address the issue, it is recommended to enclose everything in a container instead of using flex. Inside the container, create divs and place them within flex according to your needs.

Here is an example of transforming your code using tailwind play to resolve the problem.

However, when implementing this code in your .tsx file, remember to substitute class with

className</code to ensure changes are reflected on the local system.</p>
<p>You can also view the demo below. For better visualization, please view the page in full screen.</p>
<div>
<div>
<pre><code><script src="https://cdn.tailwindcss.com"></script>
<div class='container p-4'>
  <div class='py-5 px-5 lg:px-3 2xl:px-0'>
    <div class='text-2xl uppercase font-bold'>
      <h1>Appointments</h1>
    </div>
    <div class='flex flex-col space-y-4 mt-3 outline-none'>
      <Tab.Group>
        <Tab.List className="flex space-x-3">
          <Tab as={Fragment}>
            {({ selected }) => (
              <button
                className={
                  (selected ? 'bg-gray-500 text-white px-3 py-2 rounded-md font-bold' : 'bg-gray-700 px-3 py-2 rounded-md font-bold')
                }
              >
                Approved
              </button>
            )}
          </Tab>
          <Tab as={Fragment}>
            {({ selected }) => (
              <button
                className={
                  (selected ? 'bg-gray-500 text-white px-3 py-2 rounded-md font-bold' : 'bg-gray-700 px-3 py-2 rounded-md font-bold')
                }
              >
                Waiting for approval
              </button>
            )}
          </Tab>
        </Tab.List>
        <Tab.Panels>
          <Tab.Panel>
            <div class='flex flex-col space-y-4 mt-3 outline-none'>
              <table class='border-collapse border border-slate-500 w '>
                <thead>
                  <tr>
                    <th class='border border-slate-600 p-3 w-3/5'>Song</th>
                    <th class='border border-slate-600 p-3 w-1/5'>Artist</th>
                    <th class='border border-slate-600 p-3 w-4/5'>Year</th>
                  </tr>
                </thead>
                <tbody className="text-center">
                  <tr >
                    <td class='border border-slate-600 p-3'>The Sliding Mr. Bones (Next Stop, Pottersville)</td>
                    <td class='border border-slate-600 p-3'>Malcolm Lockyer</td>
                    <td class='border border-slate-600 p-3'>1961</td>
                  </tr>
                  <tr>
                    <td class='border border-slate-600 p-3'>Witchy Woman</td>
                    <td class='border border-slate-600 p-3'>The Eagles</td>
                    <td class='border border-slate-600 p-3'>1972</td>
                  </tr>
                  <tr>
                    <td class='border border-slate-600 p-3'>Shining Star</td>
                    <td class='border border-slate-600 p-3'>Earth, Wind, and Fire</td>
                    <td class='border border-slate-600 p-3'>1975</td>
                  </tr>
                </tbody>
              </table>
            </div>
          </Tab.Panel>
          <Tab.Panel>
            Content 2
          </Tab.Panel>
        </Tab.Panels>
      </Tab.Group>
    </div>
  </div>
</div>

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

React component encountering unexpected prop value

In my project, I have a Modal component and a Form component. The Modal is a functional component, while the Form is a class component responsible for handling form submissions. The Modal component passes all of its props to the Form component. Within Mod ...

Tips for modifying the cache when utilizing the API with query parameters through the useSWRInfinite hook

In my React application, I have been utilizing the useSWRInfinite hook for fetching data. One issue I have encountered is that when updating the cache using the "mutate" feature, it works as intended when the URL does not have any parameters. However, if ...

Animating Divs with jQuery to Expand their Size

I am currently designing a services page for my portfolio website. The layout consists of three columns, with the central column containing a large box and the left and right columns each containing three smaller boxes. These smaller boxes function as clic ...

The jQuery toggle function is malfunctioning when applied to the rows of a table

I have been experimenting with toggling table rows using jquery. Initially, the state is hidden This feature is functioning properly $('.table tr.items.' + name).each(function() { $(this).show(); }); Furthermore, this snippet of code is wor ...

Is it possible to view the CSS of a PDF file in print template mode using Chrome?

https://i.stack.imgur.com/XlcWm.png Currently facing an issue with debugging CSS on my PDF template. I am unable to inspect the styles directly in the CSS due to limitations. When using inspect element in Chrome, only the styles for text and elements are ...

How can you refresh the .replaceWith method in jQuery?

Is there a way to reset the .replaceWith function so that the html, css and javascript elements are restored to their original state? I am looking to have an icon replace the text when the user clicks on "contact", and then have the text return when the u ...

Increase and decrease a counter in Javascript by clicking on two separate image tags, with increments and decrements between 1 and 10

Hello! I really appreciate your help. I am currently facing the following issue: <div id="thumb1"> <img class="img-responsive" id="prova" src="img/thumb-up-dark.png" alt=""> <div id="pinline">0</div> ...

Is there a Material UI dialog popup that features an icon at the top?

My goal is to incorporate a dialog box with an icon at the top, like shown here: https://i.stack.imgur.com/0Kf10.png However, my current result looks like this: https://i.stack.imgur.com/WFcgh.png ...

The :before pseudo element doesn't seem to be functioning properly on Internet Explorer 11

The following code works well in Chrome and Mozilla, but unfortunately does not function correctly in IE11. I am attempting to apply a background color on hover to a div with the class .border-green, however this functionality is failing specifically in ...

"Create a notification pop-up in CSS that appears when a link is clicked, similar to

I am looking to create a model page that functions similarly to the inbox popup on Stack Overflow. When we click on the inbox icon, a small box appears with a tiny loader indicating messages or comments. The box then expands depending on the content inside ...

JavaScript Processing Multiple Input Values to Produce an Output

Hello, I am working on creating a stamp script that will allow users to enter their name and address into three fields. Later, these fields will be displayed in the stamp edition. Currently, I have set up 3 input fields where users can input their data. He ...

Having difficulty managing asynchronous functions with the useState hook in React

import React from "react"; import { UserContext } from "./../contexts"; import { removeStoredAuthData, storedAuthIsValid, storeNewAuthData, } from "./../utils/auth"; import { getUserInfos } from "./../api/userAuthen ...

Preserve the original color of links in CSS by using the `a

Is it feasible to specify in CSS that a link should not change its color and instead use the default one? For example: If I have text displayed in red, and that text is also a hyperlink. Typically, when clicked on, the text would change to blue because i ...

Utilizing the empty space to the right of an image in HTML

What could be causing the empty space to the right of my image? This is how the HTML file appears: ... <body> <div class="image"> <img src="image.jpg" alt="Picture here" id="image" align="middle"></img> </div> ...

What is the technical process behind conducting A/B testing at Optimizely?

I'm currently experimenting with Google Analytics and Content Experiments for A/B testing on my website, but I'm encountering some challenges in making it seamless. To utilize the Google API properly, a few steps need to be taken. Firstly, I nee ...

Is it possible to utilize Bootstrap Icons as bullet points on a website?

Is it possible to use Bootstrap icons for bullet points with CSS? I am aware that FontAwesome can be used for this purpose, but I would like to confirm if the same can be achieved using Bootstrap. Though there is a method using: <ul> <li>< ...

What is the process of sending a component as props using props in react?

Currently, I am utilizing the react-grid library provided by dev-express. Within this library, there is a Table component that allows us to pass in a Cell component. In my CustomCell component, I have integrated the Menu component from Material UI. < ...

Retrieving a list of numbers separated by commas from an array

Currently, I'm retrieving data from a MYSQL database by executing the following SQL command: SELECT GROUP_CONCAT(MemberMemberId SEPARATOR ',') AS MemberMemberId FROM member_events WHERE event_date = "2000-01-01" AND Eve ...

Setting today's date as the default option for the Material UI datepicker

I'm having trouble setting today's date as the default in my React app using Material UI datepicker. Here is the snippet of my code: <TextField id="dateTimeFrom" type=" ...

How does React determine if a component is a class component or a functional component?

Within my React application, I have successfully developed both a class component and a functional component. However, I am curious about how React is able to distinguish between the two when calling them. Can you shed some light on this distinction? This ...