A
A
akgndkut2015-11-02 22:02:25
css
akgndkut, 2015-11-02 22:02:25

How to align the contents of a block to the center?

How to align the content of a div, but if there is not only text centered horizontally?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Serov, 2015-11-02
@akgndkut

Option 1:
Wrap the content in a div, give it a width and margin: auto;
Option 2.
If absolute, then you can use negative margin:
1. Set the width (eg 200px);
2.left: -50%;
3. And give a negative margin of half the width of this block (in this case, margin-left: -100px)
https://jsfiddle.net/005nsd85/ - negative margin

A
Alexander Pupkin, 2015-11-02
@sakrab

text-align:center;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question