Exploring the world of flexbox and experimenting with implementing flex-wrap at a specific breakpoint

I am working on a layout that includes a module containing various content. My goal is to have the progress bar, along with the labels "parts" and "projects," positioned underneath an image and expand to the full width of the module when the window size goes below 640px. However, my current solution does not seem to be effective. Any suggestions or ideas would be greatly appreciated. The title text should always remain next to the image regardless of screen size.

<script src="https://cdn.tailwindcss.com"></script>

<div class="rounded-2xl flex bg-[#3B4E6A]">
  <div class="flex">
    <div class="h-20 w-20 md:w-[160px] md:h-[160px] mr-1 md:mr-1 md:ml-0.5 flex-shrink-0 m-1">
      <img src="https://placehold.co/120x120">
    </div>
  </div>
  <div class="w-10/12">
    <p class="mb-9 text-white font-semibold text-lg lg:text-2xl mt-1 ">some stuff here</p>
    <div class="w-full bg-white rounded-full h-1 text-white"> Bar </div>
    <div class="flex mt-2 align-bottom sm:align-baseline">
      <div class="text-white mt-[12px]"><span class="font-medium"></span> <span>Item 1</span></div>
      <div class="text-white ml-1 mt-[12px]"><span class="font-medium"></span> <span>Item 2</span>
      </div>
    </div>
  </div>
</div>
</div>

Answer №1

To ensure the progress bar and the text labeled "parts" and "projects" appear beneath the image and expand to the full width of the module when the window width is below 640px, you can employ responsive design techniques. This can be achieved by adjusting the layout using flexbox and media queries. Below is the modified code:

<div class="rounded-2xl flex flex-col md:flex-row bg-[#3B4E6A]">
    <div class="md:w-[100px] md:h-[100px] lg:w-[160px] lg:h-[160px] m-1 flex-shrink-0">
        <img src="https://placehold.co/400x400"> 
    </div>
    <div class="w-full md:w-10/12">
        <p class="mb-4 text-white font-semibold text-md lg:text-2xl mt-1 w-full xl:w-2/4"> Title stuff here</p>
        <!--this part should go below the image and expand to the full width of the module - the bar ,the and the parts and projects text-->
        <div class="flex flex-wrap">
            <div class="w-full bg-white progressBar dark:bg-gray-progressBar rounded-full h-[10px] sm:mb-3">
                <!-- Progress bar content here -->
            </div>
            <div class="flex w-full mt-3 text-white">
                <div class="w-1/2 md:w-auto flex items-center">
                    <span class="font-medium">1</span>
                    <span class="ml-1">Parts</span>
                </div>
                <div class="w-1/2 md:w-auto flex items-center">
                    <span class="font-medium">1</span>
                    <span class="ml-1">Projects</span>
                </div>
            </div>
        </div>
    </div>
</div>
  1. Enclosed the content within a flex container with flex-col for mobile layout and md:flex-row for larger screens.
  2. Adjusted the width of the image container and content container based on screen size (md:w-[100px], md:w-10/12).
  3. Utilized flex-wrap to enable content wrapping if needed.
  4. Modified the layout of "parts" and "projects" text to occupy full width on smaller screens (w-full for mobile, w-1/2 for larger screens).
  5. Included a flex class to ensure proper alignment of "parts" and "projects" text.

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

Increase the height of an element based on the content of the text within

Today I am facing a challenge: I need the text below to change when I click on one of these icons: https://i.sstatic.net/28xEF.png Luckily, it works with the following code: CSS .games-text { background-color: $color-primary; & p { m ...

Using Javascript, display an image that was previously hidden with CSS when a radio button is selected

Within a table of 25 rows, each row contains an attribute accompanied by an image (represented by a tick symbol) and five radio buttons for rating the attribute from 1 to 5. Upon clicking one of the radio buttons, the hidden image (tick symbol) should beco ...

Webgrid columns lose their width after a postback event

I'm working on a simple webgrid that has 3 columns: View columns: grid.Columns( grid.Column("Applicant Name", format: (item) => @Html.ActionLink((string)item.Name, "EditApplicant", "Applicant", new { id = item.ApplicantId }, null), style: "AppN ...

Using inline CSS to apply conditional styles to a component in React is a great way to customize the

I'm currently working on customizing the styles of some buttons depending on their 'active' status and whether the user is hovering over them. So far, it's partially working but I'm encountering behavior that I can't fully com ...

Display full desktop version on mobile devices with minimized view and no need for horizontal scrolling

While it may seem unusual, my client has requested temporarily removing responsiveness from the site to view the desktop version on mobile. I initially tried removing the responsive meta tag, but encountered horizontal scrolls on the page. My goal is to di ...

Different Div Sizes Based on Device Type (Bootstrap)

I am currently working on a Bootstrap 3 website and have several small divs displayed on the page. I want to adjust their size for desktop view and make them full width for mobile view. Here is my approach: I attempted to place each small div within a co ...

Once the database fetches and displays 500 results, the HTML/CSS formatting begins to

On my local webserver, I have a page running off SQLite as its database. Since it is used locally and loads results quickly, displaying all of them on one page isn't a concern. However, I'm facing an issue where the formatting goes awry after 500 ...

What is causing the bootstrap nav-bar to not open on smaller screens?

This nav-bar functions properly on screens larger than 640px, but on smaller screens, the menu button does not display the menu items when clicked. You can view the site here. <nav class="navbar navbar-inverse"> <div class="container-fluid" ...

What is the best way to adjust the size of an image within a div element using HTML?

I've created a Carousel with 5 images to display. However, I'm having an issue where only the image is showing up, and I want the text and button to appear below it. Here's how the nature image is currently displaying: What I want is for th ...

I seem to be encountering an issue with the image tag while working with HTML code

I have been studying through freecodecamp.org and this is my first tribute project. Everything has been going well, but I am encountering an issue with the image tag. I need to submit my project online, so I have been trying to input image links from Googl ...

How can you eliminate a line from the HTML input mask in Gravity Forms?

With Gravity Forms, I am utilizing the "input masks" feature to prompt users to enter data in a specific format. However, it seems to be creating an unwanted line within the input field itself as shown in the image below: https://i.stack.imgur.com/8gQ3K.j ...

Use HTML to showcase an image that dynamically changes based on the outcome of a query function

Hello there, I hope my inquiry is clear enough. I apologize for reaching out as I am unsure where to begin and what exactly I should be focusing on. Currently, I have an image displayed in an HTML page like this: <div id="tag_sunrise_sunset"><p ...

Maximizing spacing for element alignment using space-evenly and :after

I have employed the pseudo-element :after to left-align the last line of a list of blocks, using space-evenly to justify these blocks. However, I am facing an issue where the blocks on the last line do not align properly with the others due to the space ta ...

flexbox layout with a fixed sidebar that stays in place

Is there a way to make the sidebars in the holy grail layout sticky using flexbox? Specifically, I want the aside and nav sections of the HTML to stop scrolling down further once the last element is reached. I've tried various methods but with limited ...

Enhancing the appearance of the active menu item with HTML/CSS/JS/PHP

Here's the HTML code I have: <ul class="navigation"> <li><a href="index.php">Home</a></li> <li><a href="index.php?content=about">About us</a></li> </ul> As you can see, the content of the " ...

Mastering the use of SVG icons in Angular 4+: A comprehensive guide

I have an icon.svg file with a collection of icons that I would like to use in my app, similar to how we display material icons. Does anyone have any ideas on how to include the file in the app and use these icons? I've tried looking for solutions a ...

Troubleshooting the issue of the background of element A not changing when hovering over element B, despite mouseleave not

Currently, I am attempting to modify the background of element A when mouseover event occurs on element B, and then revert it back to its original state upon mouseleave. It's worth noting that B is nested within A. Strangely, while the background colo ...

Tips on how to perfectly position an element in the middle of an HTML

I am struggling to get the textarea element centered using margin: 0 auto. I even attempted to place the element inside a div with margin: 0 auto style. <div style="margin: 0 auto;"> <textarea rows="4" cols"100"></textare> </div& ...

Utilizing jQuery for dynamic horizontal positioning of background images in CSS

Is there a way to set only the horizontal background property? I've tried using background-position-x and it works in Chrome, Safari, and IE, but not in Firefox or Opera. Additionally, I would like to dynamically set the left value of the position. ...

Cross-browser compatibility problem: Firefox not displaying layout properly

I am encountering browser problems, as well as issues when using the same browser on a different computer. The links on my website are not positioned correctly over the background. When viewing with Firefox, the opacity and positioning features are not fu ...