What is the best way to stop form groups from overlapping in Bootstrap 4?

I've implemented a Profile Edit form in my React app using Bootstrap 4.

While the form displays correctly on larger screens, such as desktops, I'm facing an issue on smaller screens like mobile devices. The form-groups are overlapping each other, causing elements to be out of place. For example, in the problem image provided below, you can see that the Profile Photo placeholder image is overlapping with the First Name field instead of pushing it down as intended.

I suspect this issue may be related to how I'm utilizing the Bootstrap Grid system or handling the form-groups. Can anyone identify where I might have gone wrong?

For reference:

JSFiddle: https://jsfiddle.net/v9fpfxyo/

CORRECT:

https://i.sstatic.net/9BTyy.png

PROBLEM:

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

Snippet from JSFiddle:

<div class="container">
   <form>
      <div class="row">
         <div class="col-lg-3 col-sm-12">
            <div class="form-group" style="height: 100%;">
               <label for="files">Change your profile photo</label>
               <span>
                  <div class="" style="width: 100%; height: 100%; font-size: 0px; margin-bottom: 1rem; background-color: rgb(29, 161, 242); background-image: url(&quot;https://abs.twimg.com/a/1498195419/img/t1/highline/empty_state/owner_empty_avatar.png&quot;); background-position: 50% center;">
                     <!-- react-text: 85 -->Try dropping some files.<!-- /react-text --><input type="file" accept="image/jpeg, image/png" multiple="" style="display: none;">
                  </div>
                  <button type="button" class="btn btn-secondary btn-sm btn-block">Upload new Photo</button><!-- react-text: 88 --><!-- /react-text -->
               </span>
            </div>
         </div>
         <div class="col-lg-9 col-sm-12">
            <div class="form-group">
               <label>First Name</label>
               <div><input type="text" name="first_name" value="XXX" placeholder="First Name" class="form-control"></div>
            </div>
            <div class="form-group">
               <label>Last Name</label>
               <div><input type="text" name="last_name" value="XXX" placeholder="Last Name" class="form-control"></div>
            </div>
         </div>
      </div>
      <div class="row row justify-content-end">
         <div class="col-lg-9 col-sm-12"><button type="submit" class="btn btn-primary">Save Changes</button></div>
      </div>
   </form>
</div>

Answer â„–1

Dealing with this type of issue has been a common occurrence for me as well. My solution involves leveraging media queries to address it effectively. I suggest adding a class to the appropriate grid (col-lg-9 col-sm-12) and applying a margin-top of 30px on smaller screens using @media (min-width: 780px).

Feel free to try out this approach and let me know if it resolves your issue.

Answer â„–2

Adjusting Margins OR Implementing Css Code for mobile media width with specified margin.

margin-top: 110px;

Illustration:

<div class="col-lg-9 col-sm-12">
            <div class="form-group" style="margin-top: 110px;">
               <label>First Name</label>
               <div><input type="text" name="first_name" value="XXX" placeholder="First Name" class="form-control"></div>
            </div>
            <div class="form-group">
               <label>Last Name</label>
               <div><input type="text" name="last_name" value="XXX" placeholder="Last Name" class="form-control"></div>
            </div>
         </div>
      </div>

Answer â„–3

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
   <form>
      <div class="row">
         <div class="col-lg-3 col-sm-12">
            <div class="form-group" style="height: 100%;">
               <label for="files">Choose a new profile picture</label>
               <span>
                  <div class="" style="width: 100%; height: 100%; font-size: 0px; margin-bottom: 1rem; background-color: rgb(29, 161, 242); background-image: url(&quot;https://abs.twimg.com/a/1498195419/img/t1/highline/empty_state/owner_empty_avatar.png&quot;); background-position: 50% center;">
                     <!-- react-text: 85 -->Add files here.<!-- /react-text --><input type="file" accept="image/jpeg, image/png" multiple="" style="display: none;">
                  </div>
                  <button type="button" class="btn btn-secondary btn-sm btn-block">Upload New Picture</button><!-- react-text: 88 --><!-- /react-text -->
               </span>
            </div>
         </div>
         <div class="col-lg-9 col-sm-12">
            <div class="form-group" style="margin-top: 110px;">
               <label>First Name</label>
               <div><input type="text" name="first_name" value="XXX" placeholder="First Name" class="form-control"></div>
            </div>
            <div class="form-group">
               <label>Last Name</label>
               <div><input type="text" name="last_name" value="XXX" placeholder="Last Name" class="form-control"></div>
            </div>
         </div>
      </div>
      <div class="row row justify-content-end">
         <div class="col-lg-9 col-sm-12"><button type="submit" class="btn btn-primary">Save Changes</button></div>
      </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

What is the process for implementing filtered HTML attributes in a directive?

I’ve created a custom directive that generates a popup menu by extracting data from HTML content. The purpose is to transform a group of Bootstrap carousel-compatible elements into a structured list. However, each .item element contains an attribute with ...

"Add a touch of elegance with a jQuery hover fade effect

Here's a CSS class I'm using: #right_menu a { color: #002C6A; display: block; font-family: 'DINPro-Bold'; font-size: 15px; height: 20px; padding: 15px 0 15px 95px; width: 205px; } And the hover effect for this class is: ...

Can Vue.js import both element-ui and Bootstrap components?

After importing element-ui components, I realized that I also need some common styles such as reset.css and others from Bootstrap. I am wondering if these two can coexist in the same project without causing conflicts? ...

How come the absolutely positioned element is nested within the first "row" relative div rather than its immediate parent div?

I have a specific goal in mind: I aim to create two rows, each containing three columns. I have used relative positioning for the rows, with three images in each row for a total of two rows, and this is working well. My next step is to add layered divs b ...

Continuing the Grid

I'm working on a solution where the grid should be filled with empty squares when it's empty. And as we add items to the grid, the number of empty squares should decrease accordingly, not the other way around. <span class="box"> ...

Positioning a floated element to align with its parent container

In the scenario of a div and a series of nested divs with float: left properties, how can you ensure that the right edge of the last div in the sequence remains attached to the right edge of the parent div even when the parent div's right edge moves? ...

When using the HTML a tag, it can create unexpected gaps and

I have a sentence written in PHP that I've separated into individual word components using the explode function. foreach ($words as $splitword) { echo $splitword; /* echo "<a href = 'word.php?word=" . $splitword . "'>" . $spli ...

Utilize Flexbox to position a group of items in the center of the page, while placing a single item at the bottom for added emphasis

I have utilized Bootstrap 4 along with some custom CSS to create a hero section where all items are centered both horizontally and vertically. The only exception is one item that I want to align at the bottom of the page while still keeping it centered ho ...

Skrollr triggers a fade-in effect once the user reaches a specific distance from the bottom of the

Using skrollr, I have a div positioned at the bottom of some content that I want to fade in once the screen reaches its level. I attempted various examples found on their cheat sheet but had no success. This div is situated above the footer (500px from t ...

Ways to tailor media queries to a particular browser

While exploring an online course on advanced responsive design, I came across this intriguing question in the Q&A section. After finding a solution and sharing it, I decided to also post it here for anyone facing the same dilemma. The challenge lies i ...

The iframe refuses to center when I adjust its size in the CSS document, but mysteriously shifts to the center when I resize it in the HTML document. I am determined to find a way

My iframe is left aligned and I'm having trouble centering it. .iframeContainer { display: inline-block; justify-content: center; /* Center the iframe horizontally */ align-items: center; width: 1067px; height: 600px; } < ...

scrolling through horizontal bootstrap thumbnails

Hey there, I'm currently working on making the bootstrap thumbnails fit into a Div that has a horizontal scroll. However, I've run into an issue where they are collapsing beneath it instead of being offset properly as shown in the image. Does any ...

Is zone.js responsible for the issue of CSS not being rendered properly?

My print preview CSS is functioning properly in my current location after testing it on various browsers and computers. However, when accessed from a location in Japan, the CSS does not seem to work correctly, specifically affecting the <table>. Use ...

Error encountered in jQuery 3.3.1: Unable to append a row to the tbody of a table

As I attempt to dynamically insert a row into an HTML table when a click event occurs using JQuery 3.3.1 and Bootstrap 4, I encounter a slight issue. HTML: <table id='tblAddedCallsign' class='table table-striped'> </table> ...

What is the best way to specify the content that needs to be paginated in ui-Bootstrap

I've been utilizing ui-Bootstrap and attempting to set up pagination, but it seems like I'm overlooking a key element. Despite reading through the documentation and examining numerous plunkers for guidance on how they define the content to pagina ...

Does renaming a page to index.html have any impact?

After restarting my laptop, everything was back to normal. Thank you for the help and replies. The issue I'm facing is with two identical pages that have the same code. The only difference between them is the file names - index and index2. However, f ...

Ways to adjust the height of one panel based on the height of surrounding panels

I have a layout with three panels: two on the left side and one on the right. <div class="row"> <div class="col s6"> <div class="panel"> content1 </div> <div class="panel"> ...

What is the best way to determine the location of just one element?

I am currently working on a rating application where only the selected circle should remain green, not all of them. $('#rating-container').click(function () { var element = $('#target'); var container = $('#rating-containe ...

Offspring that has opacity will not be able to show up beneath the sibling of their parent with z-index

I'm perplexed by the behavior of stacking order when applying an opacity level other than 1 to a child element. It seems that setting any other opacity value causes the child element to always dominate its siblings in terms of stacking. .element ...

Elements in other columns being forced down due to Bootstrap column placement

Here is an example of the code illustrating the issue I am facing: <div class='body'> <div class="container"> <div class="col-md-12"> <div class="col-md-6"> Content on Left </div> <div class ...