Expanding beyond the maximum width in a two-column layout (using TAILWIND CSS)

Before I pose my question, let me quickly go over the relevant code:

The Homepage Component

const Home = () => {
  return (
    <div>
      <div>
        {questions.map((question) => (
          <div key={question.id} className="mb-4">
            <Question
              title={question.title}
              contentPreview={question.contentPreview}
            />
          </div>
        ))}
      </div>
      <Card className="p-4">Side Controls</Card>
    </div>
  );
};

The Question Component

const Question = ({ title, contentPreview }) => (
  <Card className="p-4 break-words">
    <h1 className="mb-4 text-lg text-blue-600">{title}</h1>
    <p className="text-gray-500">{contentPreview}</p>
    <div className="flex mt-4 gap-4">
      <InfoIcon
        icon={<HeartIcon />}
        info={20}
        iconClassName="text-red-400 w-6 h-6"
        infoClassName="text-gray-500"
      />
      <InfoIcon
        icon={<CommentIcon />}
        info={40}
        iconClassName="text-blue-400 w-6 h-6"
        infoClassName="text-gray-500"
      />
    </div>
  </Card>
);

The Layout Component that wraps Homepage

const Layout = ({ children }) => (
  <div className="bg-gray-100">
    <div className="flex flex-col min-h-screen">
      <NavBar />
      <div className="mt-4 max-w-7xl self-center w-full px-4">{children}</div>
    </div>
  </div>
);

Now, let's take a look at some screenshots depicting the issue:

First, a screenshot showing the background of the Homepage Component for clarity: https://gyazo.com/b8aa356912f973f854299c665c66de76

Next, a screenshot showcasing the div containing the questions in a reddish color, and the controls/sidebar in green: https://gyazo.com/2ceb6a1277f1de4506531a2bcf0b9b17

Lastly, the main issue arises when attempting to place the controls and list of questions side by side. By using the "flex" class on the container div of both elements, the controls extend beyond the intended boundaries: https://gyazo.com/af6206b95dc684bbcb316a8d33362b62 If you have any insights or solutions to this problem, please share. Thank you in advance.

(Please refrain from suggesting the use of Bootstrap or another UI framework, as I am specifically utilizing Tailwind CSS and prefer to remain within its constraints.)

Answer №1

I would like to have the controls and list of questions next to each other

To achieve this layout, you can apply flex flex-1 to both sections for equal width distribution. Alternatively, you can set a specific width for each section, such as using flex w-8/12 for the question section and flex w-4/12 for the controls section.

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 recommended to use separate Controllers for each tab in Angular JS to load the pane?

Recently delving into the world of Angular JS and eagerly seeking expert advice and suggestions. Would it be advisable to use separate controllers for initializing each Tab to load the Pane content? Is assigning separate controllers a recommended approac ...

Node.js: Managing multiple occurrences of the same event name for testing purposes

When it comes to unit testing using mocha, I am looking for a way to set up an asynchronous queue for handling events. Previously, I used a once() Promise to wait for events like this: import EventEmitter from 'events' import { once } from ' ...

Tips for enabling the wrap property with autogeneratecolumn set to true

In my grid view, I want to ensure that any text in a column that exceeds the width of the column will either wrap within the column or display on a new line. Below is the code for the grid view: <asp:GridView ID="GridView1" AllowSorting="True" runa ...

Steps for creating a rubber compound with reduced elements

Sample Image Looking for a way to reduce the size of elements on a webpage without adapting them? I want the elements to shrink and align in a single column, and I will handle the adaptation myself. HTML: <!-- Trading --> <div class="main-co ...

Show the total of a JavaScript calculation in a designated input box

Is there a way to show the total sum of this calculation in an input field? function calculateSum1() { var sum = 0; //loop through each textbox and add their values $("input.miles").each(function() { //only add if the value is a number ...

The benefits of lazy loading page components compared to ES6 Imports

Currently, I am working on a project where we are implementing lazy loading at the route level in our application. import { Suspense, lazy } from 'react'; const AppRoutes = lazy(() => import(/* webpackChunkName: "App" */ './r ...

"Beginner's guide to utilizing JQuery and AJAX with PHP

I am struggling to grasp the concept of using AJAX and jQuery to post data without reloading the page. Specifically, I am facing issues with the form reloading the page and not updating variables. Here is the code I have been working on: Initially, I was ...

mention a numerical value/heading within a JSON list

I encountered an issue while searching through a JSON array filled with Google fonts. The fonts are structured by family -> files -> filename. However, I noticed that sometimes the filename is saved as a number. For example (refer to the bottom of th ...

Sending an AJAX request from one subdomain to another subdomain within the same domain

Is it true that cross-domain ajax requests require a 'proxy' server to be used? But what if an ajax request is made from server1.example.com to server2.example within the same domain of example.com? Would that still not work? I've noticed ...

Issues have arisen with the ReactNative Jest snapshot test, resulting in a

I decided to incorporate TypeScript into my react-native project. I came across this helpful article and followed the instructions step by step. However, when I ran yarn test, I encountered an error that I'm unsure how to resolve: FAIL Components/__ ...

What steps can I take to create a responsive jQuery UI buttonset?

I am currently facing a challenge with my web app (http://www.tntech.edu/cafe-menu.php) which is being iframed into a mobile application developed by ATT. The button sizes vary on different phone models, and I am seeking a solution to make them responsiv ...

How do I transfer a constant from a vanilla JavaScript file containing DOM elements to my Express server?

Implementing Firebase authentication on my website, I'm looking to pass the user const into Express for routing purposes. Here's the function responsible for creating a new user: const signupForm = document.getElementById('signup'); if ...

Error handling proves futile as Ajax upload continues to fail

Utilizing a frontend jQuery AJAX script, I am able to successfully transfer images onto a PHP backend script hosted by a Slim framework app. However, there is one specific image (attached) that is causing an issue. When the backend attempts to send back a ...

Difficulty loading AJAX with autocomplete feature. Any suggestions?

I have created a jQuery autocomplete feature that works correctly, but when the value is removed using the Backspace key, the 'LOADING...' message remains visible instead of hiding. How can I make it so that after removing the value with the Back ...

Rotate a sphere in three.js in order to align the mapped image of the globe with the GeoJSON data that is displayed in the same three

I have successfully implemented a globe in three.js with an image mapped onto the sphere. Furthermore, I am utilizing the ThreeGeoJSON library to visualize geojson data on top of the globe. However, the geographies from the geojson data do not align corr ...

Ensure that the body background image remains stretched and perfectly centered regardless of the screen resolution

I am having an issue with vertical centering on a website I created. Everything looks fine on my monitor, but at higher resolutions, the tables don't align in the center and the image shrinks. How can I ensure that everything stays aligned properly? ...

JQUERY function fails to execute following the invocation of an array

There is an array named NAME being created. Weirdly, the code seems to be functioning fine for alert('test1') but encounters an issue when reaching alert('test2') $(document).on('submit','form',function() { ...

Remain on the current webpage following the submission of comparable ajax-forms

Seeking assistance with an issue involving Ajax that I believe is unique. Desired Outcome I have a newsfeed with various posts and interspersed forms, such as polls, for user interaction and submission of results. Objectives Users should be able to inter ...

"Using HTML to assign a unique identifier to an image within

Apologies in advance for any errors as I am relatively new to html. I am attempting to construct a table with images that have onclick events, so that each clicked seat is tracked and its id is added to a list to change the class. Each image has been give ...

How is the CSS selector affected by the presence of an asterisk (*)?

Take for instance the following code snippet: (I am familiar with using a star in CSS selectors, but not with '> *') .row > * { float: right; } And then there's this one: .row.uniform > * > :first-child { mar ...