A
A
Alexander Sharomet2015-10-06 17:19:21
css
Alexander Sharomet, 2015-10-06 17:19:21

How to vertically align a block using css?

Hello.
My question is: I am using bootstrap

<div class="container">
<div class="row">
<div class="col-sm-6">Hello</div>
<div class="col-sm-6">Hello</div>
</div>
</div>

.row{
display:table;
width:100%
}
.col-sm-6{
display:table-cell;
vertical-align:middle;
float:none;
}

When using this code, everything is vertically centered. But when the size of the .container becomes 100% then the problems start, the container shrinks to the left because the .row in bootstrap has -15px on both sides and I set its width to 100%. That is, .container - 100% > .row - 100%. of course everything breaks down.
How can I fix this, maybe there are some styles? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Komarov, 2015-10-06
@sharomet

Centering in CSS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question