How to position elements vertically?

Sorry for the noob question. Typeset a very long time - it was my hobby. Now decided to repeat.
How it is now customary to position the elements together vertically?
For example, given the markup:
the <div>
 <img href>
<h2>text</h2>
<p>paragraphe</p>
</div>

You need to set the distance between the elements img, h2 and p vertically. How now do? In advance very grateful.
June 5th 19 at 21:15
4 answers
June 5th 19 at 21:17
In this case, it is very convenient to position using flexbox, but it is necessary to rotate the main axle.

1) Ask the parent, in this case, the diva display: flex;
2) Turn the main axis using the flex-direction: column;
3) Set a uniform alignment of the content justify-content: space-around or justify-content: space-around;
space-around makes the padding top and bottom, and space between pushes extreme elements to the edges of the parent
4) as we turned the main axis, you can set horizontal alignment using align-items: center;

Gottovo :)

Example - https://codepen.io/you_web/pen/JveOQM

This implementation is good because no matter how many items in the parent Flex container you are made, they will be automatically aligned
Thank you so much! - porter_Kulas94 commented on June 5th 19 at 21:20
June 5th 19 at 21:19
Fixed margins between blocks are always asked with margin.
h2 {
 margin-bottom: 24px;
}
Thank you so much! - porter_Kulas94 commented on June 5th 19 at 21:22
June 5th 19 at 21:21
hi. read more of this article: https://habr.com/post/340420/
Thank you so much! - porter_Kulas94 commented on June 5th 19 at 21:24
June 5th 19 at 21:23
Personally I'm leaning towards 2 ways:

1. Unilateral margin
https://csswizardry.com/2012/06/single-direction-m...

2.Use mainly padding on the principle of LEGO.
You can read here or here.
Thank you so much! - porter_Kulas94 commented on June 5th 19 at 21:26

Find more questions by tags CSSLayoutHTML