今日の人気記事

  1. 入力候補から文字列を検索「Two levels collapsable lists」
  2. 年月の選択ボタンを実装「Multiple Month Picker」

改行をしないで英単語にハイフンを挿入(ハイフネーション)「Finnish Hyphenator」

当ページのリンクには広告が含まれています。

スポンサーリンク

改行をしないで単語にハイフンを挿入するプラグイン「Finnish Hyphenator」を紹介します。

jQueryプラグイン「Finnish Hyphenator」

2段カラムの英文雑誌や論文では行末に長い単語がきた場合に改行するのではなくハイフンを挿入していますね。この単語を2つに分けてハイフンで繋ぐことを「ハイフネーション」というらしいです。

このプラグインを使えば、それ(行末に長い単語にハイフンを挿入)を実現することができます。

スポンサーリンク

それではデモページのつたない英文をご覧ください。

「Finnish Hyphenator」のデモ

デモのソース(HTML + jQuery)


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="Finnish Hyphenator のデモでーす。">
<title>Finnish Hyphenator Example</title>
<style>
.hyphExample{
  max-width:200px;
  margin-right: 20px;
  padding: 0 10px;
  border: solid 1px blue;
  float:left;
}
.justify{
  text-align: justify;
}
</style>
</head>
<body>
<section>
  <h1>Finnish Hyphenator のデモです。</h1>
  <div class="hyphExample">
    <h2>ハイフンなし</h2>
    <p class="justify">Hello. My name is Webkaru. How are you? I'm fine. I have three dictioneries.</p>
  </div>
  <div class="hyphExample">
    <h2>ハイフンあり</h2>
    <p class="justify hyph">Hello. My name is Webkaru. How are you? I'm fine. I have three dictioneries.</p>
  </div>
</section>

<br style="clear:both">
<footer style="margin-top:20px">
<a href="https://webkaru.net/jquery-plugin/finnish-hyphenator/">「jQueryプラグインまとめ」に戻る</a>
</footer>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/jquery.finnishhyphenator.js"></script>
<script>
$(function() {
  $("p.hyph").finnishHyphenator();
});
</script>
</body>
</html>
スポンサーリンク

関連記事(一部広告含む)