Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #454168

    Hi, what codes would I use to globally change the line height for text on my site?

    I would like everything that is set to size 33px to have 42px line height and everything that is 15px to have 20px line height.

    Currently I am using this code to achieve 42px but it is doing it for all paragraph text, I only want it to do it for 33px font.

    body, body p {
    line-height: 42px;
    }

    Here is the site: http://marckdesignconcepts.com/bio/

    • This topic was modified 9 years, 5 months ago by alex5252.
    #454174

    Hey!

    It’s not possible in CSS to directly read the element current font size and based on that apply a value to another property, however there are some dynamic units you can use (em/rem):
    https://j.eremy.net/confused-about-rem-and-em/

    Regards,
    Josue

    #454177

    Would it be possible for me to apply a span class to a body of text and adjust the line-height for that span class? If so how would you recommend best doing that?

    #454179

    Setting a class to it, something like:

    Morbi vulputate egestas massa, ac varius tellus rhoncus et. <span class="custom"> Fusce sollicitudin eros sit amet tellus ornare faucibus. Praesent vestibulum lectus eros</span>, sit amet dictum erat gravida non. 
    

    And then in CSS:

    span.custom{
    line-height: 22px;
    }

    Regards,
    Josue

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.