Answer the question
In order to leave comments, you need to log in
How to correctly calculate heading indents in CSS?
I'm sorting out two typographic parts of two libraries: Foundation 5 and Bootstrap 3.
I need to put h1-h6 in order.
What do you need:
html { font-size:16px; }
$base_size = 16;
font-size: (44/$base_size)rem.
line-height, margin-top, margin-bottom
. margin-top: 0.2rem;margin-bottom: 0.5rem;
font sizes are different. But it is achieved at the expense of a large line-height. Because if h6 becomes a lot of lines there will be a clear display problem. h1 {
font-size: (44/$base_size)rem;
line-height: (44*1.25/$base_size)rem;
}
h2 {
font-size: (37/$base_size)rem;
line-height: (37*1.25/$base_size)rem;
}
h3 {
font-size: (27/$base_size)rem;
line-height: (27*1.25/$base_size)rem;
}
h4 {
font-size: (24/$base_size)rem;
line-height: (24*1.25/$base_size)rem;
}
h5 {
font-size: (18/$base_size)rem;
line-height: (18*1.25/$base_size)rem;
}
h6 {
font-size: (16/$base_size)rem;
line-height: (16*1.25/$base_size)rem;
}
Answer the question
In order to leave comments, you need to log in
You are trying to solve the problem head-on, not realizing that there is no general solution. How many documents I have retyped - everywhere the indents are different. A lot depends on the font, the document itself or the site, the direction of the site. You can set indents in different ways, and which one is better also depends on the situation. And a purely mathematical approach to the question is fundamentally wrong. As a technically minded person, I came to the conclusion with great difficulty that one way or another, a lot of design has to be decided by eye. Fonts have different weights, a point can occupy a different area relative to the pin area, and it can be located with an offset up or down.
The same goes for relative heading sizes. In some projects, h1 may differ from regular text only in style.
You should learn more about modular scale and vertical rhythms. A visual representation of their work is here: www.gridlover.net/app
Regarding the implementation - for modular scale there is a corresponding sass gem , for vertical rhythms - different options, for example, the same compass .
Regarding the amount of indentation - this is determined separately for each part of the project. Use the outer-inner rule to set general indentation values, and vertical rhythms to set specific values.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question