The <p>
tag often times has browser-defined margins by default, or if you use a CSS library like Bootstrap, so that could be causing your -webkit-line-clamp
on Safari to seem like it's not working or is buggy.
In my case, I had a <p>
with a pre-defined margin-bottom
value inside of a <div>
that caused the subsequent lines past the -webkit-line-clamp
limit to be revealed.
On Chrome & Firefox, the following works fine:
<div class="parent">
<p>Some really long string of text here that eventually gets clamped</p>
</div>
.parent {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
On Safari, since the inner <p>
had a margin-bottom
, it affected the height of the parent <div>
by making the parent taller, and revealing the subsequent lines.
So, my cross-browser solution was:
.parent {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
.parent > p {
margin-bottom: 0;
}