Read more content to popup
i have this description
what i want is if the content is going beyond line 3 it should have this
more...
and when we click it should open the whole content into a popup
what i did is, as i am using tailwind. i restraint the content to 3 line with line-clamp-3
but i can't add more after it. so i added a span with More.. and added onClick
to open a popup but now the problem is even when the content is not of 3lines it still shows more
the solution i found on internet says i need to calculate the line-height to determine if the content is of 3 lines but still the problem is if the content is of 3lines but it is not touching the last point suppose there's only 3 words on last line
it'll look like this
some content. more...
whats the better way of doing this?30 Replies
Stack Overflow
Creating a "read more" link that extends the content on the page
I would like to create a read more link that would extend a paragraph already being shown to reveal the entire text on the same page. If this could be solves with HTML5 and CSS, I would like that, ...
what about this
ok nvm u have to constrain it to 3 lines
perhaps u can still follow the same solution but dynamically add lines to the p tags based on the line numbers
for that u need to figure out how to calculate line numbers
that can be done using
(element.textContent.split("\n")).length
i think
ok nah that wont work lol
m just dumbwe can calculate the number of line
by dividing the lineheight to the total height of the tag
but what if the content doesnt touch the ending?
it look this one
i made this function that can calculate the line number
the issue here is i had to set the line height
otherwise the default is "normal"
ig u can just set it in css
or hardcore the value in js to whatever the normal value is
well about that, my idea is we can just append thsi bit or text (more...) at the end of the description
with span
ya
which will have an onclick
with my current setup i am using lineclamp so it hides🥲
lol
imma see if i can make one using this method
yes pleaseeeeeee
that means alot
for now i have managed to do this
@Israr
the only flow is the read more or less is separate than the p description
i added resize event to make it be 3 lines always
the original height being an issue in this case
this isnt working for me?
maybe doing something wrong 😅
i set width to
p
so it overflow the textalso i needed the text to appear in a popup as i mentioned above 🥲
i updated the code i sent above
to fix this
it works for me
xD
check da vid
@Israr
ya i think this works fine
what if we have just 3lines like this? 👀
check if the line number is less than 3 or equal
if it is 3 or equal then set the display of the span to none else to inline
righttt
okaiee yaa
i can do it nowww
thank you soo muchhhhhhhh
great
welcome
another qucik question
do you know any package for react in which i can make this dragable kind of section which sticks at the bottom of the screen and when you click or drag the section it opens as drawer?
or atleast what do we call this thing so i can look for it
idk react so i dont sorry
no worriess
thank you
welcm
Are you looking for this?
https://vaul.emilkowal.ski/
ohhhh yes!
thank youuuu