简体   繁体   中英

Calculate and pass on percent font-size from text to title

does anyone know of a combination of function to pass on font-size from one element to another.

Let's say my 'p' font-size is set at 90% and I want my font-size to be 1.5 larger than that, so in percentages that's 135%. (Like 150% is 1.5 larger than 100%). Is there a way in jquery or php to do so?

I'm quite new to all this.. I've tried the following in php but would'nt know how to use it for font-size.

$old = '90%';

    $new = ((int) rtrim($old, '')) * 1.5;

    echo $new.'%';

But it seems to me there must be something in jquery that could help me..

Anyone? Thanks in advance!

Here's a solution using PHP :

<?php
    $old_size = '90';
    $new_size = $old_size * 1.5;
?>

<p style='font-size:<?=$old_size?>%'>This is the old size</p>

<p style='font-size:<?=$new_size?>%'>This is the new size</p>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM