The issue of Bootstrap form fields not remaining within their parent div persists

I need assistance with creating a bootstrap form that is visually appealing on both web and mobile platforms. The standard markup doesn't seem to be working effectively. This is an angular application, but I don't believe angular is causing the issue...

One of the problems I am facing is when I try to group multiple fields within a div to add a background color, the fields overflow and extend beyond the left side of the div.

Another related issue is that on mobile devices, the fields have 0px left and right margins, giving it an unattractive appearance.

Here is the current markup:

in index .html:

<html lang="en" ng-app="myApp">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>My BS App</title>
  <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> 
  <link rel="stylesheet" href="css/app.css"/>
</head>
<body>
  <div class="container">
    <div class="header">
      <h3 class="text-muted">My BS App</h3>
    </div>
    <div class="row">
      <div class="col-md-6">
        <div ng-view></div>

The angular view directive is causing the form to appear as follows...

<form class="form-horizontal" name="parentForm" role="form" novalidate mb-submit="save()">
    <fieldset>
        <div ng-repeat="parent in family.parents()">
            <legend>{{parent.firstName}} {{parent.lastName}}</legend>

            <div class="row">
                <div class="form-group">
                    <div class="col-md-10">
                        <div class="checkbox">
                            <input type="checkbox" ng-checked="parent.list" ng-model="parent.list">List parent</input>
                        </div>
                    </div>
                </div>
            </div>

            <div style="background-color:red;">Why am I unable to contain the following?

                <div class="row">
                    <div class="form-group">
                        <div class="col-md-10">
                            <input type="text" placeholder="First name" name="firstName" class="form-control" ng-model="parent.firstName" required>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group">
                        <div class="col-md-10">
                            <input type="text" placeholder="Last name" name="lastName" class="form-control" ng-model="parent.lastName" required>
                        </div>
                    </div>
                </div>

As a result, the fields overflow to the left side. See the issue below:

On Web....

As for the appearance on mobile devices...

Answer №1

To achieve a cleaner layout, consider eliminating the <div class="row"> elements surrounding your <div class="form-group"> elements. These classes possess conflicting left and right margins that are compounded when nested.

Answer №2

Click here for an example.

Insert a

<div class="col-md-12">

Right after the

<div class="row">

within the div that has the background-color:red;.

Here is an illustration:

<div style="background-color:red;">Why am I not containing the following?
  <div class="row">
    <div class="col-md-12">
      <div class="form-group">
        <div class="col-md-10">
          <input type="text" placeholder="First name" name="firstName" class="form-control" ng-model="parent.firstName" required>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <div class="form-group">
        <div class="col-md-10">
          <input type="text" placeholder="Last name" name="lastName" class="form-control" ng-model="parent.lastName" required>
        </div>
      </div>
    </div>
  </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

Styling Material UI height in select elements (React)

Currently, I am developing a react application that utilizes Material Dashboard. I am encountering an issue with the height of a Select (drop-down list) component. See image here On the right side of my app, there is a standard input field and I would li ...

the side panel is positioned under the main content

Can anyone help me figure out why my sidebar is not positioning correctly next to the content on the right side? No matter what I try, it keeps going underneath the content. Here's the CSS code I'm using: body { font: 10pt Calibri, Helvetica ...

Steps for incorporating "about minutes ago, about hours ago, etc;" into a .filter for an Angular/Ionic v1 project

Can someone help me figure out how to incorporate phrases like "from now," "ago," etc. into a JS filter in my ionic v1 project for WordPress without using UTC Date? I am currently working on an Ionic v1 app that is native to WordPress, so it's crucia ...

Conceal the vertical scrollbar while allowing horizontal scrolling to remain enabled

I'm attempting to create a layout with HTML/CSS where there is a div that can be scrolled vertically and horizontally, but I only want the horizontal scrollbar to be visible. The vertical scrolling should be done using the mouse wheel while the horizo ...

JavaScript failing to retrieve JSON information from PHP

I seem to be encountering an issue when trying to read JSON data that I create in PHP and send back to my JavaScript. The problem is puzzling me. Here's the PHP code: header("content-type: text/json"); curl_setopt($ch,CURLOPT_URL, $url); curl_setop ...

Changing Meteor Template to a Node.js/AngularJS Conversion

My current website is built with Meteor using templates structured like this: <body> {{>section1}} {{>section2}} {{>section3}} </body> <template name="section1"> <h1>This is Section 1</h1> </template> ...

Example of AngularJS UI-Router Login Feature

Currently, I am delving into the realms of angularjs and bootstrap to develop a web application that will consist of two distinct sets of views - public and private. In the public view, all users will have access to it and there will be a specific top men ...

align the button to the left using bootsrap configuration

Is there a way to align a button to the left using bootswatch/Litera, which is a bootstrap 4 beta theme? I attempted to use the float-left class on the button and place it inside a div, but the outcome remained the same. https://i.sstatic.net/qs4zU.png ...

How to Vertically Align an HTML Element Inside a Div with Changing Height

Similar Question: Issue with vertical alignment Is there a way to ensure that the <a></a> is always vertically centered within this div, regardless of its size? View example here Thank you! ...

CSS issue encountered: "Value of property is not valid"

When working with CSS, I encountered an error stating "Invalid Property Value" while inspecting the transform element of the Service section in the Wall Street theme. Could someone kindly assist me with the necessary steps to rectify this issue? https://i ...

A guide on utilizing radio buttons to delete specific rows within a table with the help of AngularJS

My current issue involves using radio buttons to delete rows in a table. The problem I'm encountering is that multiple rows are being deleted at once instead of just one. You can view an image of my table here. As we all know, with radio buttons, onl ...

Obtain specific styling for an element within an Angular directive

I have a question about displaying styles on an angular element. Is it possible to do so? <div ng-repeat="x in ['blue', 'green']" class="{{x}}"> <h3 insert-style>{{theStyle['background-color']}}</h3> ...

Efficiently showcase connected pages in real-time

I've come across an issue with my express app. Whenever a navigation link (such as Home, Home1, or Home2) is clicked, an error occurs. However, if I manually type in http://localhost:8001/home1, it displays home1.html without any issues. What I' ...

What is the best way to create a slideshow using an IFrame?

Currently seeking a solution for an iframe slideshow that can smoothly transition between multiple HTML iframes. I have a total of 5 iframes that need to rotate automatically and continuously. Any suggestions on how to build a lively and dynamic iframe sl ...

Submitting a form using jQuery when the form is nested within a table

Why are forms not submitting with jQuery inside tables? I've tested form submission outside of a table and it works fine, but as soon as I wrap it inside a table, it stops working. I tried adding an extra parent() to adjust for the form moving above t ...

Enhance Material-UI's SwipeableDrawer by incorporating a clickable handle

Is there a way to include a clickable handle in a material ui SwipeableDrawer? Something similar to what's shown on Google Maps here: Google Maps button.css position: absolute; top: 100px; left: -50px; width: 50px; height: 100px; z-index: 10000; // ...

What is the best way to interact with an element in Python Selenium once it has been located?

I have been working on a script that is supposed to retrieve the attribute of an element and then click on it if the value is true. However, I keep encountering an error in my code. This is the snippet of code I am using: from selenium import webdriver d ...

Is it possible to utilize Angular.js as a full substitute for a traditional JavaScript template engine?

While angular excels in two-way data binding and single-page applications, could it also serve as a viable replacement for a JavaScript template engine? Let's dive into the potential pros and cons of this approach. ...

What is the best way to keep a checkbox unchecked after clicking cancel?

I'm working on a bootbox script that triggers a customized alert. I need the checkbox that triggers the alert to be unchecked when the user clicks cancel. Here is the checkbox when it's checked <div class="checkbox"> <label> ...

Tips for making a central CSS gradient

I am looking to create a background gradient similar to the one shown in the image (Load more news) and also add a border style. Any suggestions on how to achieve this would be greatly appreciated. ...