I have a list of episodes that I want to have a fixed height. I tried to line-clamp-2
for the episode title that has text that is longer than 2 lines.
Everything is working on my normal PC view, even if I open Dev Tools and view it as device view, it still displays as I want, but after I use my real phone, which is iPhone to view it, it has a problem which I wasn't expecting at all because there's none when I was CSS it on my PC.
What I did, I set every episode item of mine to fixed 70px height
, have 12px padding
to left and right, and 0.25rem padding
for top and bottom. I tried the solution like this post: line clamp (webkit) not working in safari
Which is to put the overflow-hidden
and line-clamp
to the div
instead of the actual p
tag, and in the p
tag using the inline
display, but in my case, it is not working.
I'm using a tailwindCSS
to CSS my component in React
. Here's how I tried so far:
<div className="lg:h-[calc(100vh-60px)] overflow-y-scroll bg-[#222] h-[30vh] max-lg:mb-[20px]">
{listEpisode.map((item, i) => (
<Link
to={`episode-url`}
key={i}
className="w-full h-[70px] px-[12px] leading-normal
py-1 hover:text-white hover:opacity-80 hover:bg-white/20
duration-200 ease-in-out line-clamp-2 overflow-hidden
odd:bg-[#111111] even:bg-[#272727]"
>
<p className="inline after:whitespace-pre">
{item.title}
</p>
</Link>
))}
</div>
The result I get when in Dev Tools on Chrome, I set viewpoint to iPhone 6/7/8 (because I'm using iPhone 7, too)
PC with device viewpoint (working as expected):
On the actual device using safari - mine is iPhone 7 (which is not working as I expect it to be):
I don't know what's the cause of this, so I can't come up with a solution to fix it, because it was normal on PC.