Challenges with responsive layout of flex items

Utilizing Tailwind CSS, I have designed this div element: https://i.sstatic.net/FDloP.png

However, an issue arises when the div is resized: https://i.sstatic.net/Sq309.png

Using white-space: nowrap causes it to extend beyond the div boundaries. https://i.sstatic.net/vl3IR.png

I am struggling to resolve this problem. I managed to arrange it into columns for smaller screens, but preventing it from wrapping when the resolution changes presents a challenge.

Here is the code snippet for reference:

<div className='bg-gray-1000 rounded shadow border border-opacity-50 text-white flex flex-col lg:flex-row w-7/12 mx-auto justify-between p-2 mb-2 items-center md:space-x-16 whitespace-nowrap'>

            <div className='bg-primary rounded w-14 h-14 flex items-center'>
                <img src={props.logo}/>
            </div>

            <div className='flex flex-col flex-grow'>
                <div>{props.title}</div>
                <div className='flex'>
                    <div><img className='w-6 mt-1' src={props.flag}/></div>
                    <div><FaInfoCircle className='inline ml-2 text-xl'/></div>
                    <div><button className={`ml-2 rounded px-4 py-0 text-sm uppercase bg-${props.color}-600`} disabled>{props.mode}</button></div>
                </div>
            </div>

            <div className='flex flex-col'>
                <div><FaCalendar className='inline mr-2 text-xl'/> {props.date}</div>
                <div className='mt-1'><FaClock className='inline mr-2 text-xl'/> {props.time}</div>
            </div>

            <div className='flex flex-col'>
                <div> <FaUsers className='inline mr-2 text-xl'/> {props.vs}</div>
                <div className='mt-1'><FaUsers className='inline mr-2 text-xl'/> {props.slots} Slots</div>
            </div>

            <div className='flex flex-col md:pr-4'>
                <div><AiFillDollarCircle color='green' className='inline mr-2 text-xl'/></div>
                <div className='mt-1'><AiFillTrophy className='inline mr-2 text-xl md:text-2xl'/> {props.prize}</div>
            </div>

    </div>

Answer №1

If you prefer to keep your font sizes large but still want a clean layout, consider wrapping your three columns on the right in a flex container with the property justify-content: space-between. This will help adjust the spacing based on available space.

Since your left content title seems to be dynamic and potentially lengthy, consider limiting the text width and utilizing the text-overflow: ellipsis property. This way, you can display long text alongside other content without overflowing.

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

Issue with Laravel css not being correctly processed by the elixir function in xampp environment

After creating a versioned css file with the following code: elixir(function(mix) { mix.sass('demo.scss') .version('css/demo.css'); }); The file can be found at public/build/demo-34f5737738.css. According to the documentation, ...

"Exploring the functionalities of repeat and minmax in tailwind - a comprehensive guide

Hey there, I have a question about using repeat and minmax in grid with Tailwind CSS. I tried the following code but it didn't work as expected. const DetailedAssetCard = () => { return ( <div className=" bg-gray-100 rounded-lg grid ...

ASP:Menu: Want to style bulleted lists using CSS

I am currently utilizing ASP:Menu and I would like to customize the menu display as outlined below. Can you please advise on how to implement the CSS styling and what modifications are required? Products Instock Out-of-Stock Orders Purchase Orders Sa ...

Box Pattern with Pop-Up Modal

Check out the grid of squares I've coded below: <div class='square-container'> <div class='square'></div> <div class='square'></div> <div class='square'></div& ...

Use regular expressions to automatically generate HTML attributes in your styling

My ionic/angular app generates a custom tag element with a unique _ngcontent attribute on each refresh, like so: <tag _ngcontent-hgr-c2>...</tag> (1st refresh) <tag _ngcontent-agj-c7>...</tag> (2nd refresh) <tag _ngcontent-cfx-c5 ...

Is there a way to stop the navbar from covering the title?

Looking for help with customizing my navbar. At the moment, it resembles image one but I'm aiming for the appearance of image two. Any suggestions on how to achieve this? Is it a CSS modification that needs to be made? /* Nav Bar*/ .navbar-brand{ ...

Why does the second JavaScript form validation not function correctly when compared to the first?

Here is a form that I have created: <form action="next.html" id="userInput" method="post" onsubmit="return validate();"> Age: <input type="text" name="age" id="age"/> function validate() { var age = document. ...

Is there a way to prevent the context menu from appearing when tapping on an image on a mobile phone?

When attempting to move an image on the screen with a touch event, a popup appears in Chrome when pressing and holding the image. This popup usually includes options to save the image. Is there a way to disable this popup so I can freely move the image w ...

Enhancing elements with CSS by adding transformations and box shadows upon hovering

My card component using material UI has a hover effect with a transforming animation, as well as a shadow that should appear on the card. However, I am facing an issue where the box-shadow appears on the box before the transformation, creating white space ...

Trouble with the Rotate <text> feature in Internet Explorer 11 on Windows 10

I am using d3.js to draw SVG with the transform:rotate(180deg) property. It displays perfectly on Chrome, but doesn't work on IE11. I tried changing it to rotateY(180deg), and it works with div elements but not with text elements. Here is my screen an ...

What is the best way to store selected items from a multi-select box in AngularJS that is generated using ng-repeat?

I have a scenario where I need to handle a group of select boxes instead of just one. Each select box holds a different option, and when the user changes their selection, I want to save that value in a variable or an array. I've managed to do this for ...

When using the "Content-Disposition" header with the value "inline;filename=" + fileName, it does not necessarily guarantee that PDF files will be displayed directly

When a link is clicked, I want the PDF file to first show in a new tab as a preview before allowing users to download it. I researched and found advice suggesting that including these two headers would achieve this: Response.AddHeader("Content-Dispositio ...

Ways to prevent the selection of images

Whenever I click on the ball, a click event is triggered. However, sometimes it doesn't work because I accidentally select the image and it interrupts the click event. I attempted to remove the selectable property using the following CSS properties, ...

JQuery function within the "onclick" event

$('.more').click(function showFriendInfo(id) { $('#MoreFriendInfo'+id).toggle(); }); I created this function called showFriendInfo(id), but how can I properly link it in HTML/PHP to obtain the id? I attempted the following ...

Creating an email body using css and html from a file on Android - how can it be done?

After searching extensively, I have come across a plethora of solutions on how to load HTML into the body of an email intent. However, I am struggling to find a way to load a file that contains CSS and HTML content. I have a specific program in which I dis ...

The z-index property does not seem to apply to pseudo elements

I am facing an issue while trying to add a pseudo element after a div in my react project. Surprisingly, the code works perfectly fine in CodePen but fails to work on my local machine. I have applied z-index only in CodePen, which seems to resolve the issu ...

Encountering issues with integrating an external plugin with AngularJS code

For my app, I am attempting to incorporate intercom for monitoring user activity. It functions correctly when placed inside a script tag in index.html. However, I encounter an error when trying to use it in a .ts file as shown below: app/components/rocket/ ...

Utilizing CSS, Javascript, and Jquery to Toggle a DIV's Visibility Based on Clicking Either of Two Images

Need help with showing and hiding divs based on image clicks. Have 2 images (Image_A and Image_B) and 2 hidden Divs (Div_A and Div_B). If Image_A is clicked, show Div_A. If Image_B is clicked, hide Div_A and show Div_B. This should work both ways, ensurin ...

What is the best way to achieve this smooth scrolling animation on the page?

While browsing the website , I noticed a unique page scrolling effect that caught my eye. Unsure if they were using default bootstrap code or their own custom code, I was intrigued by how it worked. I attempted to find similar effects online but struggled ...

Moving the mouse over a div will alter the heading of another div

Trying to find a solution for a unique problem. I have 5 boxes and need to style one box with a different heading color. As I hover over the other 4 boxes, I want the active box heading to change to a new color. The color should remain even after moving th ...