In Bootstrap 4, the Form-Inline module experiences alignment issues on extra small (XS) view

Boostrap 4 has been used to create a .form-inline at the bottom of the page. It appears correctly when the viewport is larger than the XS breakpoint...

https://i.sstatic.net/UYaG7.png

...but encounters issues when switching to XS view...

https://i.sstatic.net/IL34O.png

...based on my understanding, the subscribe button should move below the input field in XS view.

Here is the code that was implemented...

<div class="col-md-6 col-lg-4 order-first order-md-6 align-self-center">

    <form class="form-inline justify-content-center">

        <div class="form-group">

            <input type="email" class="form-control mr-2 mb-2" id="EmailInpue" placeholder="Join our Mailing List" />

        </div>

        <button type="submit" class="btn btn-primary mb-2"><i class="far fa-envelope-open"></i> &nbsp;Subscribe</button>

    </form>

</div>

...the issue was resolved by placing the button within the same form-group div as the input element...

<div class="col-md-6 col-lg-4 order-first order-md-6 align-self-center">

    <form class="form-inline justify-content-center">

        <div class="form-group">

            <input type="email" class="form-control mr-2 mb-2" id="EmailInpue" placeholder="Join our Mailing List" />

            <button type="submit" class="btn btn-primary mb-2"><i class="far fa-envelope-open"></i> &nbsp;Subscribe</button>

        </div>

    </form>

</div>

...although generally, according to Bootstrap guidelines, the button should be outside of the form-group.

In any case, this adjustment seems to have fixed the problem.

Answer №1

It's recommended not to place the button within the same form-group as the input because the default behavior of form-group only includes margin-bottom.

There are a couple of ways to resolve this issue.

  1. Option 1: Place the button inside its own form-group.

<div class="form-group">
  <button type="submit" class="btn btn-primary mb-2"><i class="far fa-envelope-open"></i> &nbsp;Subscribe</button>
</div>

  1. Option 2: Leave your code unchanged but remove the margin-bottom from the form-group.

<div class="form-group mb-0">

I'd recommend going with the second approach.

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="col-md-6 col-lg-4 order-first order-md-6 align-self-center">

  <form class="form-inline justify-content-center">

    <div class="form-group mb-0">

      <input type="email" class="form-control mr-2 mb-2" id="EmailInpue" placeholder="Join our Mailing List" />

    </div>

    <button type="submit" class="btn btn-primary mb-2"><i class="far fa-envelope-open"></i> &nbsp;Subscribe</button>

  </form>

Answer №2

Success! Placing the button code within the same form-group div as the input field has resolved the issue...

<div class="col-md-6 col-lg-4 order-first order-md-6 align-self-center">

    <form class="form-inline justify-content-center">

        <div class="form-group">

            <input type="email" class="form-control mr-2 mb-2" id="EmailInpue" placeholder="Join our Mailing List" />

            <button type="submit" class="btn btn-primary mb-2"><i class="far fa-envelope-open"></i> &nbsp;Subscribe</button>

        </div>

    </form>

</div>

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

Easily adjust the width of divs within a parent container using CSS for a seamless and uniform

I am designing a webpage where I have set the container width to 100% to cover the entire screen width. Inside this container, I have multiple DIVs arranged in a grid structure with a float: left property and no fixed width, just a margin of 10px. Is ther ...

jQuery animation not executing as expected due to transition issues

I'm looking to create a cool effect where the previous quote disappears and a new one appears when I click on a button, all with a smooth transition effect. In my attempt below using jQuery .animate and opacity property, I'm struggling to make i ...

Tips for updating the corresponding nav link in CSS when transitioning between pages

In order to highlight the current page in the navigation menu, one method is to use an active attribute on the nav-link of the respective page: <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link navLink ...

Tips for establishing a fixed point at which divs cease to shrink as the browser size decreases

There are numerous dynamically designed websites where divs or images shrink as the browser size decreases. A great example of this is http://en.wikipedia.org/wiki/Main_Page The div containing the text shrinks proportionally to the browser size until it ...

Guide on including a dropdown-item within the navbar

I've implemented a header with a navbar inside. I want to create a dropdown menu element, but for some reason, my item is not appearing. On this link, it looks simple: https://getbootstrap.com/docs/4.0/components/navs/ Pills with dropdowns <l ...

Adjust the width of an anchor tag

I have been experimenting with different solutions and unfortunately, I have not been successful in resolving the issue at hand. While working on a WordPress website, I encountered some challenges. Despite having some knowledge in this area, I am struggli ...

Tips on maintaining the original text hues that were established using setForeground() when a QTableWidgetItem is picked

Issue at Hand: Currently, when the first row is selected as shown in Figure 2 below, all text colors are changed to black, instead of maintaining their original style displayed in Figure 1. Is there a way to retain the original colors when a row is selec ...

Tips on adjusting the text color of the material radio button

Looking for some assistance here. I'm working with a small piece of code that combines Material UI and Angular. I have a radio button group where the text color is not changing, despite setting the SCSS value to #262D34. <mat-radio-group aria-label ...

When viewing a webpage on a small browser, the content will automatically expand to fill the

Attempting to utilize responsive CSS media queries to hide the sidebar unless the screen is large or a tablet big enough in landscape mode. It appears to be functioning properly while resizing the browser, but at a certain size, it occupies the entire scre ...

Display the Bootstrap dropdown menu on the right-hand side

I am currently working on a dropdown menu and I would like the dropdown items to be displayed on the right side. The functionality is working, but there seems to be an issue where the dropdown menu is not fully visible. The dropdown menu is located within ...

Tips for automatically displaying the scroll bar continuously on iOS 15 without requiring user interaction

We have a Web Application that displays a scroll bar for users to navigate through the content. The scroll bar functions correctly on desktop browsers and Android browsers, but not on Apple devices running iOS 15 (Safari Browser). Current Behavior : In ...

Preview your uploaded image before finalizing

I am currently working on implementing a new upload feature for users of our forum. This feature will allow them to upload a personal picture. Here is what I have developed so far: HTML <label>Profile image</label> <div class="phot ...

Steps for incorporating universal style into Angular 6/7 library

I attempted to incorporate global styles in my Angular app similar to how it's done, but unfortunately, it didn't work as expected. The library I'm using is named example-lib. To include the styles, I added styles.css in the directory /proj ...

Incorporate a Font Awesome icon into a Bootstrap 4 callout

I am having issues adding an icon to the left side of a Bootstrap 4 callout. Currently, the icon is appearing above the H4 heading. I would like the icon to be positioned on the left side before the message. I have attempted using .p:last-child but it doe ...

Guide on transporting PNG files over the boundary

I am working with two specific css commands. code h1 { background: #000000; border-radius: 6px; color: #fff; display: block; font: 40px/60px "Sans", Inconsolata, "Lucida Console", Terminal, "Courier New", Courier; padding: 40px 40px; text-align: center; ...

Tips for adjusting container wrapping to accommodate smaller window widths in bootstrap 4

Bootstrap 4 is still new to me, and I haven't had much experience working with Bootstrap 3 either. One issue I've encountered is that when I apply the class col-(breakpoint)-(span) to div elements, they don't automatically align in a single ...

The image tag in HTML is unable to display as an image within the jQuery object

After converting the object "suggestion" to a string, I have data stored in the "sugestion" variable like this: {"value":"<img src=\"http://localhost/erp/assets/images/product/123.jpg\"> 123123123 t-shirt","data":"ABC098765"} Unfortunatel ...

Can someone please explain how to apply various fonts to the text in a `<p>` paragraph using CSS and HTML?

Take a look at this image Can you provide guidance on how to incorporate various fonts within a paragraph, like the example shown in the image above? I am experimenting with the "Creative Corner" section. ...

What is the best way to incorporate a linear gradient into the background image using bootstrap?

I'm working on a react app and I'd like to apply a linear gradient of 0.7 to the background image using bootstrap. Can anyone help me with this? <Carousel.Item> <img className='banner-bg d-block w-100 bg-dark bg-gradient &apo ...

Ensuring that all of the content is adaptable across various devices, from smartphones to high-definition 1080p screens

I am currently working on making my entire content responsive. While I have successfully made the background responsive using different @media resolutions, I am facing an issue with the image in the foreground that is not scaling accordingly. I tried putti ...