Skip to content

Instantly share code, notes, and snippets.

@xiaojue
Last active December 12, 2015 05:08
Show Gist options
  • Save xiaojue/4719536 to your computer and use it in GitHub Desktop.
Save xiaojue/4719536 to your computer and use it in GitHub Desktop.
<style>
.num {width:100px;position:relative;}
.num .leftpart{width:44px;position:absolute;left:0px;text-align:right;}
.num .rightpart{width:44px;position:absolute;right:0px;text-align:left;}
.num .split{width:2px;position:absolute:right:46px;text-align:center;}
</style>
<script>
function splitNum(selector){
var num = $(selector).text(),parts=num.split("."),leftpart = parts[0],rightpart = parts[1];
$(selector).html("<span class='leftpart'>"+leftpart+"</span><span style='split'>.</span><span class='rightpart'>"+rightpart+"</span>")
}
$(".num").each(function(index,item){
splitNum(item);
});
</script>
<!-- html -->
<td><div class="num">100.23</div></td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment