Тёмный

How To Limit Lines Of Text With CSS Only 

Web Dev Simplified
Подписаться 1,6 млн
Просмотров 111 тыс.
50% 1

Doing vertical text overflow in CSS is incredibly difficult and many people think it is impossible, but that is not true. In this video I will show you 2 different ways to limit the number of lines of text in a box. I will also show you how to expand/collapse those lines of text using only CSS with no JavaScript.
📚 Materials/References:
Kevin’s Video: • How to set a maximum n...
:has Selector Video: • This Is So Much More T...
:has Selector Article: blog.webdevsimplified.com/202...
CSS Max Lines Article: blog.webdevsimplified.com/202...
🌎 Find Me Here:
My Blog: blog.webdevsimplified.com
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
⏱️ Timestamps:
00:00 - Introduction
00:48 - Webkit Technique
03:35 - My Technique
07:44 - Expand/Collapse Buttons
#CSSExpandCollapse #WDS #CSS

Опубликовано:

 

1 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 195   
@beinyourguard
@beinyourguard Год назад
what I like about Kyle's videos is that he does not edit the parts where he messes up. he acknowledges and looks for the error instead of recording it again
@ontheruntonowhere
@ontheruntonowhere Год назад
Agreed, and I like that he messes up a lot. Makes me feel better about my own mistakes.
@BGdev305
@BGdev305 Год назад
you're 100% correct.. his mistakes and corrections actually help me understand things even more.
@MrOmaromran
@MrOmaromran Год назад
and he rubs his nose immediately when he messes up.
@shreekharr3940
@shreekharr3940 Год назад
I am glad you and plenty others like it, but for me, especially in long learning sessions, can be distracting and even irritating at points.
@ontheruntonowhere
@ontheruntonowhere Год назад
@@shreekharr3940 It's free, whatcha gonna do?
@ilovelctr
@ilovelctr Год назад
Both you and Kevin and excellent, and so is the content of both of you! This is such an eye-opener. CSS is becoming such that with it it's possible to implement features which were previously only possible using JavaScript.
@MarlonEnglemam
@MarlonEnglemam Год назад
this is EXACTLY the task I've been working on and was having some trouble with because I had a lot of different scenarios and eventually one of them would just mess everything up, thank you!
@NoName-1337
@NoName-1337 Год назад
You can add "text-overflow: ellipsis;" to your styles to add the 3 dots for the overflow text if you want to.
@boring91
@boring91 Год назад
That's not gonna work.
@opjoter
@opjoter Год назад
You misunderstood the problem
@HorsiMusic
@HorsiMusic Год назад
This limits to only 1 line.
@atchaukhac7731
@atchaukhac7731 Год назад
@@boring91 it will if use it with "-webkit-box-oriented: vertical;"
@djondavid
@djondavid Год назад
Best/most useful mini CSS tutorial yet. Thank you so much for your great content.
@EvertJunior
@EvertJunior Год назад
That line limit is very nice, but the css only expand button I'm not sure is WCAG compliant and might be confusing for screen readers users so It's probably best to give it an aria-hidden prop since the entire text will be readable because screen readers don't consider css styles.
@ontheruntonowhere
@ontheruntonowhere Год назад
I was wondering about this myself, but I think aria-hidden is unnecessary in this case since the collapsed state is purely visual decoration. The complete content should always be available to assistive devices, letting the user decide whether to skip on to the next. It's a bit different than an accordion where the entire content block is hidden.
@EvertJunior
@EvertJunior Год назад
@@ontheruntonowhere but the input is a focusable element so it might confuse the user because checking the input won’t do / announce anything
@ontheruntonowhere
@ontheruntonowhere Год назад
@@EvertJunior Yes, great point. I yield!
@Crispypoyo
@Crispypoyo Год назад
I literally searched this up about two weeks ago because I needed it for a project. Thank you for this vid!
@SrinivasReddy07
@SrinivasReddy07 Год назад
Kyle, you simply nailed it as you do always. So much thank you.
@kaylemaclou
@kaylemaclou Год назад
Brilliant! Thanks Kyle ... and Kevin.
@mykalimba
@mykalimba Год назад
I thought I was experiencing déjà vu, but I wasn't... I was thinking of the video just like this that Kevin Powell released about a week ago! Same thumbnail concept, too!
@wazzadev7209
@wazzadev7209 Год назад
You have no idea how much I needed this, thanks so much man.
@___Kevin
@___Kevin Год назад
Well explained and very useful. Thank you
@ChesterRivas
@ChesterRivas Год назад
Great video as always. Keep going.
@FunBSDpami
@FunBSDpami 3 месяца назад
Great job! Thanks
@moherna3323
@moherna3323 Год назад
Great content bro, very useful!
@ay2s389
@ay2s389 Год назад
Wow nice tips! Thanks!
@kuoyulu6714
@kuoyulu6714 5 месяцев назад
this is so cool and useful !
@studyingasyouwere
@studyingasyouwere Год назад
Thank you for the tips as always!
@wayneswildworld
@wayneswildworld Год назад
Love this. Thanks for sharing
@Solo_playz
@Solo_playz 2 месяца назад
What a dynamic creativity with just CSS 🤯
@abrotherinchrist
@abrotherinchrist 9 месяцев назад
Your videos are a rabbit hole of information that I can't stop watching.
@zeyouR
@zeyouR Год назад
thankyou for teaching. amazing content
@pablitocodes
@pablitocodes Год назад
Great content. Congrats on your success.
@aneliayacheva6671
@aneliayacheva6671 Год назад
oh I so needed this in one of my recent projects.. thank you, I will use it :))))))))))
@thienthuannguyenlong6830
@thienthuannguyenlong6830 Год назад
tks u verry much about your knowledge
@marufmarzuq
@marufmarzuq Год назад
Kyle this is d best video on this topic 💜💜
@shneornagar6147
@shneornagar6147 Год назад
Great content! Thanks a lot 🙏
@paulthomas1052
@paulthomas1052 Год назад
Excellent little trick. Thanks :)
@webartem
@webartem Год назад
Wonderful solution! The only thing I would do another way is the text into the button - I would use instead CSS prop "content" because it keeps all text content in markup and lets a developer use variables here (from CMS or a translation). I suppose the label is better for accessibility as well.
@shivshankarshejwal6728
@shivshankarshejwal6728 Год назад
This was good one , got to learn a lot
@mind_of_a_darkhorse
@mind_of_a_darkhorse Год назад
Great tips!
@gioba4912
@gioba4912 Год назад
You're a genius! Thanks for the tutorial.
@GstarYen
@GstarYen Год назад
You are my life saver! Thank you!
@MetuAmarachi
@MetuAmarachi Год назад
he does not edit the parts where he messes up. he acknowledges and looks for the error and he is so handsome
@broadshare
@broadshare Год назад
Thank you. The kings of css, we want a css framework from Kyle and Kevin.
@poopumpthekids4208
@poopumpthekids4208 Год назад
Very Cool idea for my project
@pritampodder12
@pritampodder12 Год назад
Wow! That's really some advanced level CSS 😘😘
@midhakhan3295
@midhakhan3295 Год назад
Great tip
@GermanEmmanuel
@GermanEmmanuel Год назад
Just what I needed
@avneet12284
@avneet12284 Год назад
This was so amazing
@-d3d9ex97
@-d3d9ex97 Год назад
great work
@IsfaharUddinNishan
@IsfaharUddinNishan Год назад
Whatever! I still watch your videos. Love you bro ❣️
@kyrill19
@kyrill19 Год назад
Kyle is so good with this. Thnx!
@codeWithMete
@codeWithMete Год назад
Hello, I just create my channel, can you support?😊
@dand4485
@dand4485 Год назад
Great video. Just curious when the next CSS battle... 😁
@theDanielJLewis
@theDanielJLewis Год назад
I'd love to see a full tutorial!
@stillready6405
@stillready6405 Год назад
Damn after years of CSS I still can learn new things from you or Kevin :D
@AleMadLei
@AleMadLei Год назад
Thank you! This looks really cool. My only concern is accesibility, I think a screen reader would not be able to transmit the CSS text content and will not linit the content shown. Do you think that could be handled CSS only?
@e-benz
@e-benz Год назад
cool tutorial, tnx
@7heMech
@7heMech Год назад
I was just about to search for how to do that!
@slim_shdy
@slim_shdy Год назад
You are a wizard ❤
@AveLenivius
@AveLenivius Год назад
Really cool
@kelvinclark3474
@kelvinclark3474 Год назад
Awesome 👍
@Vir7uaLGameplays
@Vir7uaLGameplays Год назад
Holly shoot this is life changing level thanks!
@aram5642
@aram5642 Год назад
Yes yes yes: for the vendor-prefix-free clamping technique! No no no: for text in css content (not localizable, poorly adoptable by framework components). A great video as always!
@GabrielSoldani
@GabrielSoldani 8 месяцев назад
Use together with content: attr(data-label-expand); and content: attr(data-label-collapse); if you want to keep it localizable and outside your CSS.
@FireGames25
@FireGames25 Год назад
Btw you can add lorem as a language to your code spell extension, so it stops detecting it as errors
@Amr-ep3vl
@Amr-ep3vl 8 месяцев назад
I love how you were going nice and slow and explaining things clearly. And then the "has" property kicks in and you go full throttle and I don't understand what the hell just happened :D
@ngochunglongnguyen4523
@ngochunglongnguyen4523 Год назад
This is awesome, make me want to this, add transition animation, it'll be smooth and look modern.
@alexshel8578
@alexshel8578 Год назад
this is awesome
@Tony.Nguyen137
@Tony.Nguyen137 Год назад
Using input checkbox as button is really a cool approach that I didnt know. I always hided the checkbox and used a label inside a button ❤😊
@nomad100hd
@nomad100hd Год назад
Using a checkbox is bad practice because it is not accessibility friendly.
@Tony.Nguyen137
@Tony.Nguyen137 Год назад
@@nomad100hd yeah. You‘Re right. Besides accessibility I tried the code on my ipad and didn‘t get the same result.
@edgarsilvax
@edgarsilvax Год назад
Thanks!
@WebDevSimplified
@WebDevSimplified Год назад
You're very welcome!
@dangoldsmith3039
@dangoldsmith3039 5 месяцев назад
Very cool approach… I love it thanks kyle. The only shame is you can’t smoothly animate between the checked states can you? So the boxes smoothly animate to and from the expanded style.
@randomride6057
@randomride6057 Год назад
I probably would have quit web dev by now if it were not for you, Kyle. You are the best web dev teacher out there, no paid course even compares to your videos. Thank you a million times!
@abinjoseph5028
@abinjoseph5028 7 месяцев назад
great!
@scottmacintyre7385
@scottmacintyre7385 Год назад
Thanks for the great video. I'm trying to do limited text lines with ellipsis in a table cell using css but can't get it to work. Any suggestions would be a great help.
@ElkunCoding
@ElkunCoding Год назад
Awesome.
@spoonmanchen7631
@spoonmanchen7631 Месяц назад
Can you provide tips on how to make the transition in 'p' height more smoother?
@rama3018
@rama3018 Год назад
Wow , your vidio so good bro , yeah i like to learn your vidio and practice 😂
@link2yasmeen778
@link2yasmeen778 Год назад
Superbb
@shihab3930
@shihab3930 Год назад
Just 😲 wow!
@meganweber5057
@meganweber5057 Год назад
For the second technique, how do I get text-overflow: ellipsis to work?
@fran_sar
@fran_sar 4 месяца назад
Awesome
@ElectricKota
@ElectricKota Год назад
You can even write it without has selector, just select sibling, by ~ sign, you need to move the input before paragpraph, so you must hide input and pair it with label, and then it will works even on older browsers without has() support. I use this hack for every hsmburger menu, sliding articles and so on.
@MarcoGarri-co8jn
@MarcoGarri-co8jn Год назад
Great video. Helps a lot. I there any way to implement in wordpress classic editor because after include this is deleted form page and if I use code snippet include ::before
@FoxiAndMolly
@FoxiAndMolly 5 месяцев назад
hi and great thanks. Is it possible to somehow get the expansion animate a bit slower? smooth scroll like.
@nayemalifahim6701
@nayemalifahim6701 7 месяцев назад
Make a video on an input box in which height auto increases and max-height 200px scrollbar comes
@patrickconrad396
@patrickconrad396 Год назад
Damn man the ridiculously complex series of js loops I created to do this with pictures and then seeing the simplicity of pure css is insane.
@nomad100hd
@nomad100hd Год назад
Using a checkbox is bad practice because it is not accessibility friendly. It is better to use javascript.
@calcio437
@calcio437 Год назад
Thanks
@IsfaharUddinNishan
@IsfaharUddinNishan Год назад
😃
@smohammadhn
@smohammadhn Год назад
That was magic ... 😁
@omyele9315
@omyele9315 11 месяцев назад
Cool sir
@abdulkadirpolatx
@abdulkadirpolatx 8 месяцев назад
Great
@haidubogdan8712
@haidubogdan8712 Год назад
I think a example using and would have been interesting to see. In this case you can solve the expanding animation without the need of a checkbox.
@alex4tm1
@alex4tm1 Год назад
but then you would always have to click to see the content no matter if it was 3 lines or 20, this solves that problem and when the text is short u see it all, when it's long u see a preview
@haidubogdan8712
@haidubogdan8712 Год назад
@@alex4tm1 it's related to using the "hack" checkbox as a toggle element to expand / collapse. For me this is a bit counter-intuitive. The same principle of css ~:checked rule, can be applied on details[open] { ... }
@Enkrod
@Enkrod Год назад
This is really nice but doesn't work with Firefox if you don't manually set a flag in your Browser. I'm sure it will work in a near future version, but right now it's something to keep in mind.
@mfsbo
@mfsbo Год назад
Hey Kyle, how did you edit the cursor when you placed the last cursor in multiple cursors at wrong place. It was around 1:35 mark
@nguyenvuvietanh9268
@nguyenvuvietanh9268 7 месяцев назад
can you teach me how to add transition to this wonderful thing?
@sneaky-Jay
@sneaky-Jay Год назад
There is an older technique here using the siblings css selector on the checked checkbox. But the drawback is the order of the elements inside the HTML.
@nomad100hd
@nomad100hd Год назад
It is also not accessibility friendly.
@Martinit0
@Martinit0 Год назад
Amazing! Can you code Doom in CSS?
@spreadItWide
@spreadItWide Год назад
That last minute was wild! Headed to that :has() video now!
@Trazynn
@Trazynn Год назад
Can you show us how to make a random image gallery fetching images from a folder?
@thetechie6770
@thetechie6770 Год назад
Please make a detailed explanation video on Redux
@elkcityhazard
@elkcityhazard Год назад
is has supported yet in firefox? also doesn't that input cause accessibility issues? Nice concepts anyways.
@khoinguyen-ft2ys
@khoinguyen-ft2ys Год назад
:has selector is a game changer
@sumith
@sumith Год назад
its cool
@Holy_Frijole
@Holy_Frijole Год назад
Any accessibility ramifications since we are using a checkbox in the second example?
@Martinit0
@Martinit0 Год назад
Why, the use case is actually to switch between two states. A button is actually meant to trigger an action, not switch between two states.
@revenge425
@revenge425 Год назад
my take is not really, it actually makes more sense than a button : It looks like a button but it is a check that toggle if the content is expanded or not. checkbox should be used for true and false situations and this actually is a true and false situation..
@offgridvince
@offgridvince Год назад
Thank you so much for you videos, I'm learning so much. Also, I am having a difficult time with the login tutorial. I can only get the login in route to work in deveplopment. I can't seem to get bcrypt compare to work in production with MongoDB Atlas or Compass. Please help. Thank you.
@offgridvince
@offgridvince Год назад
I'll accept knowledge from the chat as well. I reached out with comments on that video, but it's like 2 years old now. Not too active.
@mrbuster3106
@mrbuster3106 Год назад
:has() does not work on firefox, unless you unlock it via configuration. Understandably this means production code cannot use :has() selector :/
@theodorealenas3171
@theodorealenas3171 Год назад
Nor qutebrowser. And I'm meant to be able to use it, websites are text with fancy bullshits why wouldn't I be able to use it.
@sushmithasrikanth3836
@sushmithasrikanth3836 Год назад
Hello .. can you please teach how to use nodemailer to send a welcome mail automatically after a user registers
@AndreiNedelus
@AndreiNedelus Год назад
Great tips, I think instead of the + you can use ~ and will select only the siblings, witch in your code will be only 1 paragraph sibling.
@saroj_kumar
@saroj_kumar Год назад
Plus, it will also work on old browsers.
@broadshare
@broadshare Год назад
@@saroj_kumar I get maaaad every time someone mentions those old browsers😥 where are they, who is even using them? win officially killed IE
@saroj_kumar
@saroj_kumar Год назад
@@broadshare , Though old browsers are not used for personal use, there are still corporate servers and applications that use legacy or may be some previous versions of browsers. On the contrary, as a developer, it's a good practice to always check for the edge case, even if no body uses old browsers, we still have to consider someone around the world might use it and be ready for it.
@neetsmlam
@neetsmlam Год назад
nice video! it would be cool to hide the button if it is not required when the text is shorter too.. ;-)
@polymer940c
@polymer940c Год назад
great video, learn a ton, but :has is not supported in firefox...
@realdaly
@realdaly Год назад
how can I make the fade effect stick to the bottom if my container's overflow was auto not hidden?
Далее
6 Advanced Flexbox Features You Probably Don’t Know
14:54
ЭТО ВООБЩЕ НЕ БОЛЬНО !
00:15
Просмотров 368 тыс.
Super sport😍🔥
00:14
Просмотров 1,6 млн
UZmir & Mira - Qani qani (Snippet)
00:26
Просмотров 358 тыс.
Backstage or result?😈🔥 @milanaroller
00:12
Просмотров 7 млн
How To Make Tooltips With Only CSS
15:05
Просмотров 108 тыс.
Learn CSS Units In 8 Minutes
8:48
Просмотров 222 тыс.
Manual setup for a minimal Storybook
3:12
CSS Anchor Is The Best New CSS Feature Since Flexbox
15:39
10 Tailwind Classes I Wish I Knew Earlier
13:31
Просмотров 157 тыс.
Learn CSS Grid in 20 Minutes
18:35
Просмотров 765 тыс.
How To Load Images Like A Pro
15:48
Просмотров 353 тыс.
Vim Tips I Wish I Knew Earlier
23:00
Просмотров 35 тыс.
Remix Crash Course 2023 (React Framework)
2:07:00
Просмотров 87 тыс.
React Storybook Crash Course
17:28
Просмотров 328 тыс.
ЭТО ВООБЩЕ НЕ БОЛЬНО !
00:15
Просмотров 368 тыс.