Currently I have the following Form
<section class="contact bg-primary" id="contact">
<form id="main-contact-form" class="contact-form" name="contact-form" action="enviar.php" method="POST">
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Nombre *</label>
<input type="text" id="nombre" name="nombre" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" id="email" name="email" class="form-control" required="required">
</div>
<div class="form-group">
<label>Asunto *</label>
<input type="text" id="subject" name="subject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Mensaje *</label>
<textarea name="mensaje" id="mensaje" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<input type="submit" id="submit" name="submit" class="btn btn-primary btn-lg" value="Enviar" />
</div>
</div>
</form>
</section>
but it looks like this
I tried <div class="center-block"></div>
but without success
Bootstrap version * Bootstrap v4.0.0 ( https://getbootstrap.com ) Thanks in advance
If you just want to center the form, then you can use the class
mx-auto
on the container of its elements:That class adds the following CSS code that basically centers it horizontally:
You can center it without using css with d-flex justify-content-center
Put d-flex justify-content-center in the form tag
Look this is a centered form with bootstrap 4
There it is. The
col-sm-*
must be inside a.row
and the row inside a.container
must not be inside the form tag. There is the example so you can see it in full screen. Greetings, I hope it helps you.