Struggling with Bootsrap Flex and Justify-Content functionalities

I recently designed a footer with 4 columns, and the last column contains two rows of divs. I wanted the last column to be left-aligned, so I used justify-content-start for the first row, and it worked perfectly. However, when I tried applying the same style to the second row (which contains a search bar and button), the justify-content-start didn't work as expected.

After trying flex-row, I still encountered the same issue. Here is how my web view looks currently:

https://i.sstatic.net/3wik9.png

I aim for the search bar and button to align parallel to the visitor counter above. Any suggestions on how I can resolve this issue?

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aec6c1c1dacdd0d7cecfeeeffadcbdfcac6db">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">

<div class="col-lg-3 offset-lg-1">
  <div class="row mb-4 justify-content-start">
    <div class="card text-white visitor-card" style="width: 16rem;">
      <div class="card-body">
        <h5 class="card-title">Total Visitors :</h5>
        
        <!-- PHP code for calculating total visitors -->
        
        <h5 class="card-title">
          <?php echo $totalvisitors ?>
        </h5>
      </div>
    </div>
  </div>

  <div class="d-flex flex-row" style="border-color: white;">
    <div>
      <form class="d-flex" action="<?= base_url('Home/search'); ?>" method="post">
        <input class="form-control me-2" type="search" placeholder="Search articles..." aria-label="Search">
        <button class="btn btn-outline-primary" type="submit">Search</button>
      </form>
    </div>
  </div>
</div>

Answer №1

Perhaps the issue lies in the fact that the container holding the search bar is already at 100% width of its parent, making it impossible to horizontally align it due to lack of space for movement.

This is a frequent problem encountered by many, but with some CSS debugging techniques, you can quickly identify the root cause.

A useful layout debugging method involves adding a border to the div or its children that require alignment:

.container {
   border: 1px solid lime;
   outline: 1px solid lime;
}

Note: Using outline may be preferable in certain scenarios as it does not affect the element's dimensions

If your container is filling up the entire width of its parent, consider applying width: fit-content to shrink it and create room for alignment. I hope this advice proves helpful not only now but also in future endeavors :-)

Answer №2

I haven't had a chance to confirm if this is the exact issue you're facing, but it appears that Bootstrap 5.0 has removed justified text options.

It's worth noting that there are no utility classes for justified text in Bootstrap 5. Although justified text may seem visually appealing, it can make word spacing more irregular and thus more difficult to read.

https://getbootstrap.com/docs/5.0/utilities/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

Tips for utilizing fontawesome effectively in a select menu

I'm having trouble displaying fontawesome icons in a select element, as they do not appear correctly in the drop-down list. .FontAwesomeSelect { font-family: Font Awesome\ 5 Free; font-size: 18px; } <link href="https://use.fontaw ...

A dynamic jQuery plugin that replicates the smooth page sliding animation found in iPhone apps

Currently, I am in search of a jQuery plugin that has the capability to navigate users to different pages on a website with a sleek sliding animation, similar to what we see in some widely used iPhone apps. Despite my best efforts to create this functional ...

Styling a div element in React

Just dipping my toes into the world of styling here, so bear with me. I'm currently working on a React app and attempting to bring an image from a file using the following code: import cup from './img/cup.png' My goal is to style it in co ...

The issue with the stretched-link in Bootstrap 5 is that it is not functioning properly when used with a

I'm having a small issue with the stretched-link feature not working properly with my card. Despite trying everything from the Bootstrap documentation, including removing buttons as they are said to not work well with stretched-links, I still can&apos ...

I am facing an issue where the weather information is not being displayed even after sending a request to

I'm working on building an app that will provide users with weather data once they input a city. Utilizing the openweathermap.org API for this purpose, I've noticed in my console under networks that an API call is made when the city is entered, b ...

Splitting the string into individual characters using string.split("").map may cause layout issues on small devices

Shoutout to @pratik-wadekar for the amazing help in creating a working text animation. However, I encountered an issue when testing it on various screen sizes and mobile devices - the animated word plants breaks into pieces like PLA on one line and NTS on ...

Enhance text content effortlessly with an automated text augmentation feature

Essentially, what I'm wondering is whether there exists a program that can automatically add HTML tags to the text you input. For instance: Let's say I type in: "The world is beautiful" The program would then transform it into: <p align="c ...

Adjust the size of the mouse cursor in real time

I'm currently in the process of developing a project where I want to create a web application with a mouse cursor that appears as a circle with a customizable radius, which can be altered by the user. The main requirement is for this custom cursor to ...

Manipulate the content of any webpage without using external extensions by injecting your own HTML, CSS, and JavaScript code

I am currently following a tutorial on how to draw shapes on a local webpage using Canvas. I came across this helpful article on Html5 canvas paint. Everything is going smoothly, but now I am interested in replicating the drawing functions/CSS/HTML and "i ...

Experimenting with @media queries to dynamically resize images for various devices such as phones, tablets, and desktop

I'm struggling with making the background images on my website responsive. I have already added media queries to my page, but they seem ineffective and I am unsure of what else to try. Below are the HTML and CSS codes for the three images. Any suggest ...

Tips for resolving a sluggish webpage with database content

I am facing an issue with one specific page on my website that contains links to the database. The loading speed of this page is extremely slow and I'm looking for ways to speed it up. I have noticed that even when there are no visitors on the server ...

Drop-down selection triggering horizontal auto-scroll

Within my div element, I have a table with dropdowns. The div is set up to be horizontally scrollable. To create the dropdown functionality, I utilized Harvesthq Chosen. Let me provide some context. In Image 1, you'll notice that I've scrolled ...

The process of adding a tooltip icon to a Select component in Material-UI

I'm currently working with the material UI tooltip component and I want to position my tooltip to the right of a dropdown, right next to the down arrow as shown in the image below: https://i.stack.imgur.com/O2gwh.png However, the way it is set up no ...

Unexpected appearance of blank space to the right of my parallax design

Ever since a forced reboot, my parallax scrolling page has been experiencing issues. A strange whitespace seems to be throwing off the sections, only appearing every other section - one is fine, the next is offset, and so on. I've carefully gone thro ...

showing a pair of divs in a split layout on the homepage

I have a partially split homepage with two sections using Twitter Bootstrap v5.1.3 for the layout. The left side consists of two divs, one for text and one for an image. These divs are contained within a flex-parent, giving them an inline-block appearance ...

How can I remove the arrow from a CSS selector?

I'm looking to enhance the appearance of a select element on my webpage, so I've crafted some custom CSS: .selectWebDropDown { background-color:Transparent; background: url(../Images/ddl_Normal.png) no-repeat right #FFFFFF !important; ...

Tips for expanding the content of a blogger page to fill the entire frame of the page

Check out this page: . Currently, the video on the page does not fill up the entire screen. Any suggestions for a solution? ...

The dimensions of text that wraps itself around multiple lines are distinct from those of text that remains on a single line

Hello everyone, I need some assistance with setting up my WordPress blog. I have integrated both Facebook and native WordPress comments on my website: . My aim is to make the formatting of the WordPress comments resemble that of Facebook comments as closel ...

What is the best way to format each <li> element onto a separate line?

Creating a review section for an item on my website required me to organize the reviews and comments. I utilized the following code structure: <ul> <li> Comment code </li> <li> Comment code </li> </ul> Within the ...

JavaScript-enhanced HTML form validation

I encountered a small glitch while working on simple form validation with JavaScript. I tried to catch the issue but have been unable to do so. Here is the code snippet, where the problem lies in the fact that the select list does not get validated and I ...