0

I've question how to make form align to center with bootstrap.
Here's my code:

    <body>

<div class="p-3 mb-2 bg-light text-dark container text-center">
<h2>Rezervacija Stanovanje Aljaz</h2>

<br>
<br>
<label><b>Ime: </b></label>
    <input type="text" class="form-control col-sm-6" disabled value="" >
<label><b>Priimek: </b></label>
    <input type="text" class="form-control col-sm-6" disabled value="" ><label><b>Telefon: </b></label>
    <input type="text" class="form-control col-sm-6" disabled value="">
</div>
</body>
BlueMilkyh
  • 59
  • 1
  • 7

3 Answers3

1

Add CSS link of bootstrap4-5 after your title tag else write custom CSS code. text-algin: center;

1

You need to use the various Bootstrap 4 centering methods...

Use text-center for inline elements. Use justify-content-center for flexbox elements (ie; form-inline) https://codeply.com/go/Am5LvvjTxC

Also, to offset the column, the col-sm-* must be contained within a .row, and the .row must be in a container...

<section id="cover">
    <div id="cover-caption">
        <div id="container" class="container">
            <div class="row">
                <div class="col-sm-10 offset-sm-1 text-center">
                    <h1 class="display-3">Welcome to Bootstrap 4</h1>
                    <div class="info-form">
                        <form action="" class="form-inline justify-content-center">
                            <div class="form-group">
                                <label class="sr-only">Name</label>
                                <input type="text" class="form-control" placeholder="Jane Doe">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">Email</label>
                                <input type="text" class="form-control" placeholder="jane.doe@example.com">
                            </div>
                            <button type="submit" class="btn btn-success ">okay, go!</button>
                        </form>
                    </div>
                    <br>

                    <a href="#nav-main" class="btn btn-secondary-outline btn-sm" role="button">↓</a>
                </div>
            </div>
        </div>
    </div>
</section>
jahantaila
  • 840
  • 5
  • 26
1

If you are making HTML email template as you said in one of your comment.. you should use table layout or you will have problems with that template in many clients.

I don't suggest using flex in emails templates too.. but to answer your question add these classes to your first div d-flex flex-column align-items-center.

  • No problem. Also be aware that it won't be possible to send POST request (send form data somewhere) from email.. For that the best thing is to use CTA which will redirect user to website where that form will be available. – Jakub Stibůrek May 23 '21 at 22:12
  • It's not meant for that... I'll just use it as recepit or bill.... – BlueMilkyh May 23 '21 at 22:15