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.

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

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

Is it possible to create a fluid-width layout with two columns that also spans the full

I have searched tirelessly through Google and stackoverflow, but I can't seem to find a solution to my specific problem. I need help creating a container div that can hold either one or two columns. The content is generated by a CMS and may or may not ...

Preserving scroll position during page navigation in Next.js

Currently, I am working on a website using the Next.js boilerplate. Here is the routing code that I am using: import Link from 'next/link' <Link href={{ pathname: '/some-url', query: { param: something } }}> <div> ...

Having trouble editing a form with React Hooks and Redux?

Seeking assistance with creating an edit form in React that utilizes data stored in Redux. The current form I have created is displaying the values correctly, but it appears to be read-only as no changes are being reflected when input is altered. Any advic ...

React allows for items to be exchanged between two lists

I am currently working on a functionality that involves swapping items between two arrays. The user interacts with two lists in the UI by selecting items from the first list, which should then be removed from there and added to the second list where the se ...

Customize each Picker.Item element in React Native with unique styles

How can I style individual Picker.Items beyond just changing the text color? Additionally, what other props can be used for a Picker.Item? I am aware of "key", "value", "label", and "color". Are there any additional props available? I want to customize o ...

Error: The code is trying to access the property 'string' of an undefined variable. To fix this issue, make sure to

I encountered an issue after installing the https://github.com/yuanyan/boron library. The error message I received is: TypeError: Cannot read property 'string' of undefined Error details: push../node_modules/boron/modalFactory.js.module.expor ...

The conflict between Material UI's CSSBaseline and react-mentions is causing issues

Wondering why the CSSBaseline of Material UI is causing issues with the background color alignment of React-mentions and seeking a solution (https://www.npmjs.com/package/react-mentions) Check out this setup: https://codesandbox.io/s/frosty-wildflower-21w ...

Click event on MenuItem fails to trigger

I'm currently utilizing redux form in conjunction with material ui. I have an array of form templates that users can choose from as options. My goal is to retrieve the selected template, dispatch an action, and then initialize redux form with the valu ...

When I click on any input field, button, or other controls on a webpage, the page automatically zoom

I am currently trying to troubleshoot an issue with a bootstrap theme. It seems to be working perfectly on all browsers except for ios safari browsers. Whenever I click on an input field or button, the page suddenly zooms in. It's quite frustrating. ...

Error in React+Redux: Trying to access the "address" property of a null value is not permitted

I am new to using react and encountering an issue with my ecommerce app. The app runs smoothly until I log out and then log back in at the shipping address page, which triggers the following error: TypeError: Cannot read property 'address' of nu ...

Creating a unique icon using Jquery Mobile for a button in a PhoneGap application

Has anyone experienced issues with using a custom icon for a jQuery mobile button? I am having trouble as it is only showing a grey circle instead of the actual icon. The default icons work fine, though. Here is the code snippet from the index.html page: ...

Querying a body in GraphQL within Gatsby: A Simple Guide

Recently, I embarked on creating a blog by following a 2019 tutorial that utilized the contentful-plugin. However, upon researching the updated documentation from Gatsby, I encountered some discrepancies which hindered my progress. My primary issue lies in ...

Issue with Passing 'key' Prop to React Component in a Mapped Iteration

https://i.sstatic.net/qeFKT.pngI'm struggling with adding a key prop to a React component in a mapped array within a Next.js project. The issue lies in a Slider component and an array of Image components being mapped. Even though I have provided a uni ...

Utilizing CSS to incorporate percentage points

Currently, I am facing a challenge in implementing a vertical line with percentage marks. It needs to be positioned relative to the percentage bar, just like how it appears in the screenshot below: https://i.stack.imgur.com/CNWUV.png I attempted a basic ...

The command '.' is unable to be executed as an internal or external command, executable program, or batch file when using npm start -- -e=stag -c=it

After executing the command shown below npm start -- -e=stag -c=it An error is generated: ./scripts/start.js -e=stag -c=it '.' is not recognized as an internal or external command, operable program or batch file. What can be done to resolve th ...

Utilize CSS to create a column layout

I have some HTML output that I would like to style using CSS, but unfortunately I have no control over how the HTML is generated and cannot make any changes to it. Right now, I have a two-column layout set up here: http://jsfiddle.net/uvg6f3tr/ I'm ...

Mastering @media queries to dynamically alter widths in prop styled components

I have a unique component that utilizes an object with its props for styling. const CustomSection = ({ sectionDescription, }) => { return ( <Text {...sectionDescription} content={intl.formatMessage({ id: &apos ...

"Utilize HTML to make inline-block elements appear small in size while giving the illusion of being

I have a group of inline-block elements (4 total), all arranged neatly in a single row. As the window size changes, the elements wrap to the next line accordingly. The page does not display scrollbars at the bottom until the browser width reaches the minim ...

Facing challenges with integrating the stripe payment gateway within the strapi content management system

I recently developed an e-commerce website using Next.js, with Strapi as the CMS and Stripe for payment processing. Within the Strapi backend application, I integrated the API required for handling payments. Below is the code snippet: 'use strict&apos ...

Exploring necessary components for react-toggle feature

I am currently facing a challenge with integrating the react-toggle-component library into my project. After installing the necessary dependencies (react, react-circle, react-dom, and styled-components) using npm, I encountered an error message stating &a ...