Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change font size after decimal point

I am working with an Opencart E-Commerce website, I need to customize product price font size, for example: product price: $ 250.50 i need to set font size for $ = 16px; 250 = 22px; .50 = 14px;

How can I set different font sizes for a single amount..???

this s my dynamic php code that display price text to my product page:

<span class="price"><?php echo $product['price']; ?></span>

my product list page not a single product with price, there is a lots of product with price list.

thanks for any help, if anybody asked the same question before here, please share with me those links...

like image 871
mans Avatar asked Jun 18 '13 07:06

mans


2 Answers

$.each($('.price'), function(){
var price = $(this).html();
$(this).html(price.replace(/(\D*)(\d*\.)(\d*)/,'<span style="font-size:16px;">$1</span><span style="font-size:22px;">$2</span><span style="font-size:14px;">$3</span>'));
});

http://jsfiddle.net/gr8x5/10/

like image 163
ccd580ac6753941c6f84fe2e19f229 Avatar answered Oct 07 '22 23:10

ccd580ac6753941c6f84fe2e19f229


Here's a quick and dirty example:

<html>
<head>
    <style>
        .dollar_sign { font-size: 16px; }
        .dollars { font-size: 22px; }
        .cents { font-size: 14px; }
    </style>
</head>
<body>
<?
    $product = array('price' => '245.50');
    $part    = explode('.', $product['price']);
?>
    <span class="dollar_sign">$</span><span class="dollars"><?= $part[0] ?></span>.<span class="cents"><?= $part[1] ?></span>   
</body>
</html> 
like image 45
Carl Avatar answered Oct 07 '22 22:10

Carl