Forums

Dynamic line height on post title (2 posts)

  1. erikhgm
    Member
    Posted 5 months ago #

    Im using this code to dynamically create random font size of the post titles on the front page.
    http://pastebin.com/itYGXAkS

    However is there a way to do so that when the font size is 32 I can have a different lineheight from the lineheigth when the font size is 44?

  2. tugbucket
    Member
    Posted 5 months ago #

    simple example based on what you already have:

    <?php
    $font_size = array(32,44);
    $font_size = $font_size[array_rand($font_size)];
    
    if($font_size == "32"){
    	$line_height = "40";
    } else {
    	$line_height = "50";
    }
    
    echo 'font-size: '.$font_size.'px';
    echo 'line-height: '.$line_height.'px';
    ?>

Reply

You must log in to post.

About this Topic