I'm having rows like these items as h2
height: auto;
min-height: 50px;
line-height: 50px;
But if I have a multi-line h2 it looks so bad. How can I decrease the line-height of h2 if it has multi-lines to be 30px instead of 50?
I'm having rows like these items as h2
height: auto;
min-height: 50px;
line-height: 50px;
But if I have a multi-line h2 it looks so bad. How can I decrease the line-height of h2 if it has multi-lines to be 30px instead of 50?
If you know the H2 that will have 2 lines, you can give them class or ID and target them specifically with line-height of 30px,.. if the H2 becomes two lines when the screen changes(of view), you can change line-height in media query css file for big, small or medium screens!!
Okay so. If you want to increase space between lines you can use line-height
.
It is used to define the minimal height of line boxes within the element, but here is the thing. If you put it on h2
element it will be applied to every h2
element on your webpage or website.
Here are a few solutions to consider.
If you want bigger line-height
for the element you can give that element a specific class and define line-height
for that class, and whenever you need that line-height
just add class to the element. This way you will reuse classes and write less CSS.
If you want to increase space between elements you can do this in two ways. Margins and paddings. These are really simple.
If you want to push element down you can give margin-top: 10px
to it or margin-bottom: 10px
to element above it, or if you have 3 elements (like in your case) you can give
margin-top: 10px;
margin-bottom: 10px;
to middle element and it will push away top and bottom elements for 10px. Same is with padding.
There are lots of ways to achieve the same thing in programming. First, sit down and think about what is easiest to write but is readable and scalable.
Happy coding :)
Changed min-height
to 30
and line-height
to 30
with Padding top and bottom