LoginSignup
10
9

More than 5 years have passed since last update.

文字を長体に変形して指定幅に詰めるjQuery拡張

Last updated at Posted at 2015-12-26

tume.js

所定の幅に収まるように長体にして文字を詰めるjQuery拡張。
widthを指定したブロック要素に対して使う。

使い方

$(hoge).tume() innerHTMLの内容を詰める
$(hoge).tume(str) strを詰めて設定
$(hoge).tume(str,true) widthに満たない場合は広げる

サンプル

表示例:
表示例画像

実働サンプル

実際の使用例: 書誌ガチャ タイトル等を1行に収めるために使用。

仕組み

隠しdevエレメントに一旦文字を表示し、幅を測った上で、所定のサイズに収まるように、css::transformで変換をかけている。

リソース

github

10
9
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9