admin管理员组文章数量:1406914
I'm enlarging an element and attempting to change the -webkit-line-clamp
. It works in that it shows the right amount of lines after the change, but it doesn't work in that the ellipsis and link (after text) don't move to the (new) end.
View CodePen
If you click the "Make it Big" button, you'll see what I mean.
How Can I make it so that the ellipsis and link get pushed to the end after changing the -webkit-line-clamp
?
HTML:
<div class="api-family-tile-description">
A bunch of text <a href="/someplace">View more ></a>
</div>
CSS:
.api-family-tile-description {
padding: 10px 10px 0 10px;
height: 108px;
display: block;
line-height: 18px;
display: -webkit-box;
margin: 0 auto 10px;
-webkit-line-clamp: 6;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
JS:
var lineheight = 18;
var lines = 14;
$(".api-family-tile-description").css({
height: (lineheight*lines)+"px",
"-webkit-line-clamp": lines
});
I'm enlarging an element and attempting to change the -webkit-line-clamp
. It works in that it shows the right amount of lines after the change, but it doesn't work in that the ellipsis and link (after text) don't move to the (new) end.
View CodePen
If you click the "Make it Big" button, you'll see what I mean.
How Can I make it so that the ellipsis and link get pushed to the end after changing the -webkit-line-clamp
?
HTML:
<div class="api-family-tile-description">
A bunch of text <a href="/someplace">View more ></a>
</div>
CSS:
.api-family-tile-description {
padding: 10px 10px 0 10px;
height: 108px;
display: block;
line-height: 18px;
display: -webkit-box;
margin: 0 auto 10px;
-webkit-line-clamp: 6;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
JS:
var lineheight = 18;
var lines = 14;
$(".api-family-tile-description").css({
height: (lineheight*lines)+"px",
"-webkit-line-clamp": lines
});
Share
Improve this question
edited Aug 15, 2015 at 11:48
sergdenisov
8,5829 gold badges51 silver badges66 bronze badges
asked May 15, 2015 at 20:53
SmernSmern
19.1k22 gold badges77 silver badges93 bronze badges
1
-
Here's how to change
line-clamp
dynamically - codepen.io/vsync/pen/QNxeVQ – vsync Commented Dec 22, 2021 at 7:34
1 Answer
Reset to default 4Try this — http://codepen.io/sergdenisov/pen/ZGOEdz:
$(".api-family-tile-description").css({
height: (lineheight*lines)+"px",
"-webkit-line-clamp": lines.toString()
});
From http://api.jquery./css/:
When a number is passed as the value, jQuery will convert it to a string and add px to the end of that string. If the property requires units other than px, convert the value to a string and add the appropriate units before calling the method.
本文标签: javascriptDynamically changing lineclampStack Overflow
版权声明:本文标题:javascript - Dynamically changing -line-clamp - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744987416a2636174.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论