Created
April 3, 2013 01:37
-
-
Save devlights/5297764 to your computer and use it in GitHub Desktop.
htmlとjavascriptで3点リーダー表示 (text-overflow: ellipsis)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>3点リーダー</title> | |
</head> | |
<body> | |
<div id="container"> | |
<span>日本語での文字列1文字列2</span> | |
</div> | |
<style scoped> | |
#container { | |
margin-top: 10em; | |
margin-left: auto; | |
margin-right: auto; | |
width: 10em; | |
height: auto; | |
border: thin solid #000; | |
font-size: large; | |
/* 以下の3つを指定しないと3点リーダーにならない */ | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} | |
</style> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
<script> | |
$(function() { | |
var $span = $("#container span"); | |
$span.attr("title", $span.text()); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
対応しているブラウザ
https://developer.mozilla.org/ja/docs/CSS/text-overflow
IEは6.0からFirefoxは7.0から対応している。