Last active
August 29, 2015 14:07
-
-
Save shamiao/f63480c67bad75a89e36 to your computer and use it in GitHub Desktop.
SegmentFault Q1010000000724476
This file contains 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"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>bs3 Example</title> | |
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css"> | |
<!--[if lt IE 9]> | |
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script> | |
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> | |
<![endif]--> | |
<link href="http://cdn.bootcss.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> | |
<style> | |
body { padding: 50px; } | |
.divs { width:100px; border:1px solid gray; } | |
.long { width:300px; } | |
.ellipsis { text-overflow:ellipsis; overflow: hidden; } | |
} | |
</style> | |
</head> | |
<body> | |
<div class="divs operateTarget ellipsis"></div> | |
<div class="divs operateTarget long"></div> | |
<div class="divs operateTarget"></div> | |
<div class="divs ellipsis"></div> | |
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> | |
<script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$(".divs").text('very_very_very_long_text'); | |
$(".operateTarget").map(function() { | |
if (this.offsetWidth < this.scrollWidth) { | |
$(this).css('font-weight', 'bold'); | |
$(this).data('toggle', 'tooltip') | |
.data('placement', 'bottom') | |
.attr('title', $(this).text()); | |
$(this).tooltip(); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment