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

115 Views Asked by Ajeet At 04 October 2016 at 09:33 2025-12-02T13:27:09.009000

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

  • UIWebView Screen Fitting Issue
  • Website zoomed out on Android default browser
  • Twitter Bootstrap horizontal form elements on a line
  • My navbar is not expanding after collapse
  • Reload List after Closing Modal
  • Overwrite Bootstrap style for a single page
  • UI.Bootstrap Angular Typeahead and Firebase Array
  • Bootstrap - Fixed navbar doesn't do what's expected?
  • Bootstrap NavBar with no content on small screens
  • Bootstrap Dropdown Button Problems
  • ScrollBar not showing up - BootStrap
  • Bootstrap flip card with css3 transform
  • bootstrap grid layout questions
  • How do I make jquery events work in a bootstrap modal with dynamic content and selectors?
  • Using GLYPHICONS's free pngs with classes

Related Questions in CENTER-ALIGN

  • Button not center align in Safari
  • Search Box within Navigation bar alignment issue
  • Center elements inside Scrollview
  • Website left aligned on iPad in Safari and Chrome
  • Align a div to center
  • Print data frame with columns center-aligned
  • ggplot2 geom_bar: Centering bars
  • Center align of a text in a table in gitlab
  • String center-align in python
  • Is it possible to have a table in the center in a GitHub gist Markdown?
  • android center align the selected tab in tablayout
  • Center-align TextView on top of ListFragment with custom layout
  • How to make a responsive right aligned login box to center, when viewed in different screen sizes using media queries?
  • How to center an iframe horizontally?
  • Block element, horizontal center aligned and minimum width possible

Related Questions in TWITTER-BOOTSTRAP-FORM

  • This form not submit post values
  • Span image over multiple rows in form
  • django-crispy-forms bootstrap 4: How to display checkboxes horizontally?
  • bootstrap form does not send post method
  • Bootstrap adaptive Form not playing nice with Kendo multiselect
  • Place icon inside submit button using Bootstrap 3
  • Make Label Beside Input in Bootstrap 4
  • Rails 4, edit multiple model in one form
  • Show label inline on a input field in Bootstrap 4
  • input textbox larger than input-lg
  • Bootstrap: How to delete the border form?
  • How to add grid inside of the form in Bootstrap twitter?
  • Bootstrap 3 form with input fields and text data in separate rows/cells?
  • Bootstrap Form Not centered while in mobile view
  • 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

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

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