DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

I want my Bootstrap form to be centrally aligned, I have used the standard classes of BS Form, but the form always aligned to left

118 Views Asked by Ajeet At 04 October 2016 at 09:33 2025-12-25T09:28:09.665000

I used various classes for margin:0 auto, and for center-alignment but not worked.

 <div class="container">
    <div class="col-md-12 newsletter">
                <form action="#" method="post">                   
                    <div class="form-group col-md-6 col-xs-10 col-sm-10 col-lg-4">
                             <label for="email">Email address:</label>
                             <input type="email" class="form-control" id="email">
                        </div>

              <div class="clearfix"></div>

                        <div class="form-group col-md-6 col-xs-10 col-sm-10 col-lg-4">
                            <label for="email">Email address:</label>
                            <input type="email" class="form-control" id="email">
                        </div>
                </form> 
              </div>
       </div>
twitter-bootstrap center-align twitter-bootstrap-form
Original Q&A
2

There are 2 best solutions below

0
Olha Vadiasova Olha Vadiasova On 04 October 2016 at 10:10

You may add -offset- class to the div with col- classes. For example:

<div class="form-group col-md-offset-4 col-md-6 col-xs-10 col-sm-10 col-lg-4">

col-md-offset-4 will add extra space, so the input with label will be centered. For further information read this documentation

UPD You may also use flexbox. Apply this css style to your code:

.newsletter {
  display: flex;
  justify-content: center;
}

But keep in mind that you will need to remove bootstrap classes (col-md, col-xs etc) from the div with form-group class name. You can view the working example with flexbox here

HTML:

<div class="container">
    <div class="col-md-12 newsletter">
                <form action="#" method="post">                   
                    <div class="form-group">
                             <label for="email">Email address:</label>
                             <input type="email" class="form-control" id="email">
                        </div>

              <div class="clearfix"></div>

                        <div class="form-group">
                            <label for="email">Email address:</label>
                            <input type="email" class="form-control" id="email">
                        </div>
                </form> 
              </div>
       </div>

CSS:

.newsletter {
  display: flex;
  justify-content: center;
}
0
Jyoti Pathania Jyoti Pathania On 04 October 2016 at 10:11

Try this:

Check Demo here

HTML:

<div class="container">
  <div class="row">
    <div class="section-form">
      <div class="col-md-12 newsletter">
        <form action="#" method="post">
          <div class="form-group">
            <label for="email">Email address:</label>
            <input type="email" class="form-control" id="email">
          </div>

          <div class="clearfix"></div>

          <div class="form-group">
            <label for="email">Email address:</label>
            <input type="email" class="form-control" id="email">
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

CSS:

.section-form {
  max-width:550px;
  margin:auto;
}

Related Questions in TWITTER-BOOTSTRAP

  • General questions about creating a custom theme Moodle CMS
  • How to fix - The modal dissapear below 992px.?
  • Bootstrap horizontal gutters issue
  • How can I add a list of icons to the right of a text area
  • Why isn't my Bootstrap background color class working as expected?
  • Edit button in each row of table using same Bootstrap modal as add button
  • Change Opacity of Bootstrap Button
  • bootstrap 5 multiple tab dropdown with tab pane
  • Bootstrap v5.3 navbar drop-downs not working. Why?
  • Should i learn Bootstrap in 2024
  • How to turn on Bootstrap Intellisense in .NET 8 Blazor
  • Bootstrap 5.3 burger menu not responsive in Underscore WordPress template
  • Bootstrap 5 columns not displaying inline
  • Bootstrap scaffolding not showing good on mobile
  • How to Prevent Select2 Dropdown from Moving with Scroll inside a Bootstrap Vue Modal?

Related Questions in CENTER-ALIGN

  • Unordered list items slightly off center from one another
  • How do I center a UL/LI in the same row as left-aligned text?
  • String center-align in python
  • JSF Components alignment inside panelGroup
  • CSS: Cannot horizontally center by using margin
  • how to put the checkbox to the middle ? now the checkbox is skewed?
  • Center action bar title - Android
  • Center Align Modal ReactJS
  • JTextArea: Center Alignment
  • How do I vertically center align every <p> with flex display?
  • Center align of a text in a table in gitlab
  • Bootstrap Horizontal Alignment Issue
  • How to centre image and text together?
  • How do I align the image to center in the SVG regardless of changes made to image's width?
  • How to center element using tables without scrollbars?

Related Questions in TWITTER-BOOTSTRAP-FORM

  • django-crispy-forms bootstrap 4: How to display checkboxes horizontally?
  • How can I align form elements in one group
  • Show label inline on a input field in Bootstrap 4
  • Bootstrap 3 form with input fields and text data in separate rows/cells?
  • How to add grid inside of the form in Bootstrap twitter?
  • Rails 4, edit multiple model in one form
  • Make Label Beside Input in Bootstrap 4
  • input textbox larger than input-lg
  • bootstrap form does not send post method
  • Bootstrap form validation not working in angular2
  • Popup doesn't find Index page after save
  • Span image over multiple rows in form
  • This form not submit post values
  • I want my Bootstrap form to be centrally aligned, I have used the standard classes of BS Form, but the form always aligned to left
  • Bootstrap Form Not centered while in mobile view

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?
.

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Math
  • Aftereffectstemplates