So basically, I want my page to look like this. The logo (green triangle) is "images/logo.png", and the three other boxes are Username input/Password input/Submit button.
The code I have tried does not work - it squashes it all up on the left side of the page.
<div class="login-box">
<div class="row">
<div class="col-sm-2">
<img src="{{ asset('images/logo.png') }}" />
</div>
<div class="col-sm-10">
<p align="center">{{ form_widget(form.username, {'attr': {'class': 'form-control', 'placeholder': 'authentication.username'|trans } }) }}</p>
<p align="center">{{ form_widget(form.password, {'attr': {'class': 'form-control', 'placeholder': 'authentication.password'|trans } }) }}</p>
<p align="center">{{ form_widget(form.log_in, {'attr': {'class': 'btn btn-lg btn-primary btn-block'}, 'label': 'authentication.log.in'|trans }) }}</p>
</div>
</div>
</div>
<style>
.login-box {
width: 800px;
vertical-align: middle;
}
</style>
What am I doing wrong?
Thanks
You might consider using the col-sm-offset to change the position of your image and your fields. Try:
Play with "col-sm-offset-x" until you get it positioned correctly.
I have created a example demo with some dummy data but you will get the idea how to achieve it
Let's assume your parent
element
is 100%height
andwidth
of the viewport.You can easily vertically align any element, if you don't mind using the
transform
property, with a few lines of code.You can throw in a
margin: 0 auto;
if you want to horizontally align it as well (and it is a block type element).Fiddle Here
To apply it to your code:
login-box
is the element with100%
height
andwidth
.login-box
class.