What is the best way to address the excess white space between an image and progress bar on larger screens while utilizing the Bootstrap Grid system?

https://i.sstatic.net/NXMNV.pngLet's begin by visualizing the concept through these images: In Picture (1), the progress bars are positioned below the image on medium to large screens, with the text aligned to its right. https://i.sstatic.net/Cw1aM.png

In Picture (2), on smaller screens, the text comes second and the progress bars come last: https://i.sstatic.net/IOzSP.png

Here is the code snippet I have attempted:

<!DOCTYPE html>
<html lang="fr">
<!-- Rest of the HTML code omitted for brevity -->
</body>

Mark the location in red where the progress bars are supposed to be placed.

The issue arises in large screens where the text size becomes too large, causing the progress bar row to move down significantly, leaving a white gap between the image and the progress bars! Check out these screenshots:

Answer №1

To implement this strategy of utilizing Bootstrap's grid system (which, in actuality, functions more like a flex system), you can include the progress bars twice in your code (once after the image and once after the text) and manage their visibility using display utility classes (v4 docs, v5 docs).

The progress bar below the image should have the classes .d-none.d-md-block, while the one below the text should have .d-block.d-md-none. Switch the md to sm or lg for different breakpoints, and if the element defaults to "flex" display, swap *-block with *-flex classes.

View a functional demo here.

Alternatively, you could duplicate the text instead of the progress bars and apply the same technique.


Points to Note:

  • The downside of this approach is the complexity it adds to manipulating event listeners for the duplicated element or its children. Nevertheless, certain frontend frameworks (such as Vue and React) feature built-in "portal" components that can render their contents within a different DOM location based on controller logic, preserving events. As far as I know, Angular does not offer this functionality by default, but there may be a plugin available.

  • This layout can also be achieved with custom CSS by ensuring all three elements are children of the same parent, utilizing display: grid and setting grid-template-areas (or grid-template-rows & grid-template-columns) responsively. However, this would require abandoning Bootstrap's grid system for that container and crafting your own CSS for responsive column control.

  • It is not evident from the sketches whether you intend for the text to be scrollable on mobile with a fixed-top image and fixed-bottom progress bars. This configuration could result in a suboptimal user experience. A preferable approach on mobile devices is to enable full-page scrolling.

  • There are HTML markup issues present: premature closure of the <h2> tags for the title and improper closure of layout <div>s. Your IDE should typically flag these errors. Not adhering to these practices might lead to disqualification in an interview or job application scenario for not utilizing an IDE effectively.

  • Additional markup concerns include avoiding the nesting of <p> within <h*> elements (or vice versa), refraining from placing multiple paragraphs within a single <p> tag, and minimizing the use of <br> tags. Avoid placing a .row directly within another .row (wrap it within a .col instead). Ensure your code passes HTML validation checks.


I have rectified all the issues highlighted above in the provided example.

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

Customizing Material UI: Grouping Tab components within a div container

How can I wrap the children of a Material UI Tabs component in divs? <Tabs value={value} indicatorColor="primary" textColor="primary" onChange={handleChange} > <div> <Tab label="x" /> ...

Ways to create a fixed top navigation bar that adjusts content similarly to a non-fixed navbar

I'm looking to achieve a fixed navbar at the top that pushes down content when I open the collapse menu, similar to how it functions in static or regular navbars. Something like this example: (https://getbootstrap.com/examples/navbar-static-top/) but ...

How can I line up elements in different divs when the width is adjusting based on the window size?

Trying to align a search input and a result element in separate containers when the window size changes. Looking for a solution without using Javascript. One window size: https://i.sstatic.net/LiQtY.png A smaller window: https://i.sstatic.net/dgj4I.png C ...

`Is there a way to retrieve the ID of an element upon clicking on it?`

Can you help me with a JavaScript query? I have two HTML div elements with ids of 'div1' and 'div2'. When I click on any of the divs, I want to display the id of the clicked div. Any thoughts? <div id="div1"></div> <div ...

overlapping text placed directly above another text

Is there a way to place a text fragment above another part of the same line? <div>Th<div class="ac">Am</div>is is an ex<div class="ac">E</div>ample line</div> If implemented, it should display as: Am E This ...

Employing useEffect within Material-UI tabs to conceal the third tab

At the page's initial load, I want to hide the first two tabs. The third tab should be visible with its content displayed right away. Currently, I can only see the content after clicking on the third tab. To troubleshoot this issue, I attempted to use ...

Using JavaFX to create a StackedAreaChart and implementing the setLowerBound method

I am encountering some issues with the Class StackedAreaChart and setLowerBound function. When I enable the autoRangingProperty to true, everything works fine. However, when I disable autoRanging and apply certain parameters, I encounter some bugs. imp ...

What is the best way to add rounded corners to tables in Bootstrap 3?

Is there a way to give the top and bottom corners of a table rounded edges? I am currently using Bootstrap 3 tables, but they have no corner radius by default. How can I achieve this effect? ...

Selection box and interactive buttons similar to those found in Gmail

Looking to achieve these effects for <option> and <button> using CSS and JavaScript. Any suggestions on how to do this? ...

Is Bootstrap CSS Carousel malfunctioning following a float adjustment?

Currently, I am trying to implement a carousel in bootstrap, but I am facing two significant issues. The alignment of the carousel is vertical instead of horizontal (my div elements are stacking downwards). When I apply the float: left property, the carou ...

"Utilize an HTML input to query and retrieve data stored in a

Seeking to retrieve data from my MySQL database and display it on the website securely. List of existing files: /includes db_connect.php functions.php getdata.php logout.php process_login.php psl-config.php register.inc.php /j ...

Adjust the order of list items based on the resolution change

Is there a way to rearrange the order of the list items in an ul when the screen resolution changes, specifically having the last li appear in the first place? Edit: I am attempting to achieve this by using flexbox. .postpreview ul { list-style: none; d ...

The first table can be located using basic HTML parsing with simple html dom

When using simple html dom to extract ids from a table, here's what my tables are structured like: <table> <a name="Module-277409-Start_5f7bad2c-10af-4c88-afaf-6c960be2f547"></a> <a name="Module-277409-Start"></a> < ...

Retrieve the image by its unique identifier while viewing a preview of the image before it is uploaded

Below is the script I am using to preview an image before it is uploaded. The HTML structure looks like this: <div> <img id="image" src="#"> </div> <input type="file" accept="image/gif, image/jpeg, image/png" onchange="readURL(th ...

Ways to prevent styles from being overridden by those specified in JavaScript

Some elements on my page have their style dynamically changed by JavaScript. However, I want one of them to maintain its static style without being overridden. Is there a way to specify that the style of this particular element should not be altered? Than ...

Choosing a color while hovering over the navigation bar

I'm trying to modify the color of my navigation bar when hovering over it with the mouse. Currently, it's black but I want it to change to a light grey or white color. What am I missing here? HTML: <!DOCTYPE html> <html> <head ...

Unable to scroll down an overlay window using Selenium with Python

When using Quora, I am trying to scroll to the bottom of the window that appears when I click on the "View upvoters" button in order to access all the names of those who have upvoted. However, the code for scrolling down a standard browser window doesn&apo ...

Arrange and display similar objects together

I have a list of items in a listView that need to be visually grouped based on their class, displayed within boxes. For example, I have 5 items with the following classes: <div class="1"></div> <div class="1"></div> <div class= ...

A helpful tip for those working with jQuery or WordPress PHP: Use a script that calculates the number of characters in a text, identifies the last space, and replaces everything after

Is there a way to restrict the amount of text shown within a div sourced from a WordPress Custom Field? <?php $textcount = strlen(get_field('custom_quote')); ?> <?php if ( $textcount > 250 ) : ?> <?php the_field('custom ...

Attempting to change the appearance of my jQuery arrow image when toggling the visibility of content

Here is a sample of my JQuery code: $(document).ready(function() { $(".neverseen img").click(function() { $(".neverseen p").slideToggle("slow"); return false; }); }); Below is the corresponding HTML: <div class="neverseen"> <h1> ...