Top 10 CSS One Liners That Will Blow Your Mind

Поделиться
HTML-код
  • Опубликовано: 21 дек 2024

Комментарии •

  • @zachjensz
    @zachjensz 2 года назад +737

    0:45 1. Vertical Text
    1:23 2. Gap
    2:07 3. Flip an Image
    2:36 4. Smooth Scrolling
    3:25 5. Scroll Snapping
    5:54 6. Resize Everything
    6:50 7. Truncate
    7:44 8. Text Gradients
    8:55 9. Object Fit
    10:32 10. Pointer Events

    • @diplo_yt
      @diplo_yt 2 года назад +25

      Thanks man, I hate videos that dont have predefined timestamps

    • @waleedsharif618
      @waleedsharif618 2 года назад

      Thanks

    • @jenstornell
      @jenstornell 2 года назад +5

      Me too. I'll never go back to this channel again.

    • @renegroulx7029
      @renegroulx7029 2 года назад

      Zach Jensz reminds me of the guy that I cheated off during test in high school.

    • @samsg
      @samsg Год назад

      📖 scroll css

  • @kwanele_dev
    @kwanele_dev 2 года назад +918

    the funniest thing is I discovered "gap" by myself. I didn't want to use margin on my flex items, and I just thought of "gap", wrote it down and it worked 🤣🤣🤣

    • @itz-electro
      @itz-electro 2 года назад +115

      If only all programming was like this

    • @AbhishekKhareOriginal
      @AbhishekKhareOriginal 2 года назад +3

      Damn 🔥

    • @arshadtbuchori5000
      @arshadtbuchori5000 2 года назад +5

      Aint no wayyy. Wished i found out that way 😂

    • @PaulMcCannWebBuilder
      @PaulMcCannWebBuilder 2 года назад +1

      @Tris gap works in Safari, caniuse just says it doesn't work in multi-column.

    • @kingnonnnnn
      @kingnonnnnn 2 года назад +2

      @@user-jg6yz7wq3j not true! safari supports gap since version 10+ inside display grid elements. and since 14.1 inside flex elements.

  • @krupapanchal9908
    @krupapanchal9908 2 года назад +473

    1. Vertical Text => writing-mode
    2. Flex-Gap => gap
    3. Flip an image => transform: scaleX(-1)
    4. Smooth Scrolling => scroll-behaviour: smooth
    5. Scroll Snapping => scroll-snap-type: x mandatory; scroll-snap-align: center;
    6. Resize Everything => resize: both | vertical | horizontal;
    7. Truncate => --webkit-line-clamp: 1;
    8. Text Gradients => --webkit-background-clip, --webkit-text-fill-color
    9. Fix image stretching issue => object-fit;

    • @andycrazy120
      @andycrazy120 2 года назад +1

      交个朋友

    • @ghaznavipc
      @ghaznavipc 2 года назад +11

      10. Prevent from selecting => pointer-events: none;

    • @andycrazy120
      @andycrazy120 2 года назад +1

      @@ghaznavipc 交个朋友

    • @ghaznavipc
      @ghaznavipc 2 года назад +2

      @@andycrazy120 What do you mean by "To make friends"? (I translate your comment in google translate)

    • @andycrazy120
      @andycrazy120 2 года назад

      @@ghaznavipc Meet and make friends

  • @bancroftberlin
    @bancroftberlin 2 года назад +145

    "Boom, you are in the UK, bitch 😂!" You won't hear that on many other coding channels and I love it.

    • @garrysyt8461
      @garrysyt8461 2 года назад

      😂😂😂

    • @devrd5
      @devrd5 2 года назад +1

      He's real

    • @equious8413
      @equious8413 2 года назад

      Yup. Definitely rewound. Lol

    • @MatichekYoutube
      @MatichekYoutube Год назад +1

      UK AND all of the former colonies :D

    • @TareUhhhhhh2
      @TareUhhhhhh2 6 месяцев назад +1

      I love that it's the most replayed part too. Everyone was like "Wait, what? Did I just hear that?" 🤣

  • @ShadowVipers
    @ShadowVipers 2 года назад +59

    At the end of the video if you're just trying to stop the user from selecting the text (and seeing the text cursor), then "user-select: none" would be more appropriate than "pointer-events". Using "pointer-events" would be more for stopping a user from clicking an input, like a button or a text field, etc. The "pointer-events" property also has the side-effect of preventing the inspection click (Shortcut: "ctrl+shift+c") from opening in the dev-tools console (at least on Chrome) which if you're developing a website can get a bit annoying. I also saw in another comment that "pointer-events: none" also prevents hover effects, right click context menus, etc.
    Something slightly unrelated but still important that I wanted to share is:
    Do not use "pointer-events: none" instead of the "disabled" attribute on an input. This is because while it does prevent mouse/tap events, it doesn't affect keyboard navigation
    So if you're building a website with accessibility in mind it's important to consider that people can focus in on the input with their keyboards.

  • @developedbyed
    @developedbyed  2 года назад +28

    Let me know your fave css tricks that people might not know!

    • @techy_nidhi
      @techy_nidhi 2 года назад +3

      Vertical text 🤩🙌

    • @sbw94
      @sbw94 2 года назад +1

      Hey, can you update the link for the "Full Course Content" inside the JavaScript and HTML course? The Google Drive link goes to a 404 google drive page. Thanks!

    • @pawegabski5422
      @pawegabski5422 2 года назад +2

      display: none; 😂 boom

    • @HtopSkills
      @HtopSkills 2 года назад

      writing-mode

    • @evgenyurazovsky
      @evgenyurazovsky 2 года назад

      *{margin:0;padding:0}

  • @pacomedtej
    @pacomedtej 5 месяцев назад +1

    I love how you express and talk so confidently! Thanks fort the tips!

  • @PaulMcCannWebBuilder
    @PaulMcCannWebBuilder 2 года назад +19

    As a tip for text gradients (No. 8), order matters in your rule: set the background first, then clip. Or don't use the 'background' shortcut (gradients are set with background-image).

  • @domenicpolsoni8370
    @domenicpolsoni8370 2 года назад +10

    You just saved me from having to write out some JS to handle object fade in transitions. I've always had to observe animationend or transitionend events in order to manipulate the display: none style. I've been doing this for quite some time now. Thank you so much!

    • @monoffo
      @monoffo Год назад +1

      In case you are using react, I suggest you take a look at CSSTransition npm package. It simplifies animations a lot by applying different subclasses during the animation, and it allows to combine display: none with any transition very easily.
      However, I am sure that even outside react and npm there are plenty of similar solutions, so check it out

  • @rgdayo
    @rgdayo 2 года назад +20

    These were awesome Ed!
    As a full-stack dev on some legacy systems I usually loathe dealing in the CSS but these proved to me that not everything has to be difficult. I just need to keep learning.

    • @liver17
      @liver17 Год назад +2

      Is CSS legacy stuff?

    • @SirZyPA
      @SirZyPA Год назад +3

      not sure what you mean by legacy systems in a css context?
      and if you mean stylesheets that use float layouts, ususally those are pretty easy to just change into modern options like flex, grid, etc.

  • @godnyx117
    @godnyx117 Год назад +8

    I always thought that HTML and CSS can only do so little and you can only STYLE things. Now that I'm learning CSS, OMFG!!!! I don't believe how much built-in functionality it has. I'm currently in the ResizeBoth trick and I'm BLOWN AWAY!!!
    Edit: OMG! The "pointers-event" was also something I was searching for!!!

    • @babatundeadenowo7568
      @babatundeadenowo7568 Год назад +2

      When I started building UIs, I knew no Javascript and I had the non-starter syndrome of "JS is hard", so with just HTML and CSS, I had already been creating hamburger toggle menu and website dark and light mode switch. Not a drop of JS in those code.

    • @godnyx117
      @godnyx117 Год назад +1

      @@babatundeadenowo7568 Thank you for the comment! JS seems pretty easy to me, I never understood this "JS is hard" thing some people say. The more I learn, CSS is also getting more bearable and even enjoyable at some points!

  • @matthewstrauck4646
    @matthewstrauck4646 Год назад +1

    Great video! Helps me as someone who already knows the basics but doesn’t know where to go from there.

    • @lukas.webdev
      @lukas.webdev Год назад

      Maybe me new video about the Top 10 CSS Features you should know and use in 2023 will help you too? 😉

  • @shawnnosaurus
    @shawnnosaurus 2 года назад +3

    Love the sense of humour. Personally `box-size: border-box;` is my top pick, that I even recommend placing as browser resets for how powerful it is.

    • @_invencible_
      @_invencible_ 2 года назад

      yeah it really should be the default. The first time it took me so long to find out why my 100% width div with a border was overflowing

  • @chrisicotec7652
    @chrisicotec7652 3 месяца назад

    i love that on the vetical resizing "good luck finding a use for that one".... challenege accepted!

  • @HarveyMyers
    @HarveyMyers Год назад

    Thanks!

  • @tropicalverktaki
    @tropicalverktaki 2 года назад +2

    wow, scroll behavior has got to be the best one liner, I remember having to write several lines of Javascript code to achieve that effect

  • @nchutchind
    @nchutchind Год назад +2

    Using `pointer-events: none` will also cause click events to not register on things. You could use `user-select: none` to prevent just selection.

  • @letmetelluuu
    @letmetelluuu Год назад +1

    You made my day!! Learned so much productive today!! Thank you so much man

  • @maganopigadus
    @maganopigadus 2 года назад +18

    The default object-fit is not contain, it's fill.
    Also elements with display:none are not removed from the dom they just never render. they are fully accessible programmatically

  • @ArneBab
    @ArneBab Год назад +2

    object-fit: cover - that one and scroll snapping were new to me. Thank you!

  • @felipesdam
    @felipesdam 2 года назад +1

    If it weren't this video I could spent so much time to solve a task. Thank you for sharing this content. Scroll snapping blow up my mind. It helped a lot.

  • @BroScro
    @BroScro Год назад +5

    dont eliminate its pointer events to get rid of selection. that is user-select: none; and also cursor: default; will keep the cursor the same. and u can still have pointer events if u need to on that element

    • @BroScro
      @BroScro Год назад

      this is in response to number 10

  • @thepretzelball
    @thepretzelball 9 месяцев назад

    Very useful video. I stumbled upon this video and helped me solve an issue with text-truncation I was having.

  • @DerekGomez-n1w
    @DerekGomez-n1w 3 месяца назад

    I can't believe I spent so much time doing vertical text the hard way! I was using position: relative & transform: rotate !

  • @MuzicFreakNumberOne
    @MuzicFreakNumberOne 2 года назад

    wow that smooth scrolling is crazy simple, good job

  • @ac6852
    @ac6852 8 месяцев назад

    Thumbsed-up bc you got me w the clickbait title and you telling me to deal w it w the zoom in made me cackle lolololol

  • @parvizfathianpour9509
    @parvizfathianpour9509 5 месяцев назад

    💯 cool stuff, I knew one of the trick but I enjoy to see your info, thanks

  • @archer201977
    @archer201977 2 года назад +1

    Glad i found this video, thanks man! on my 13years of web development still there are tons of things that I never knew.

  • @lukas.webdev
    @lukas.webdev Год назад

    Just yesterday I also posted a video about the Top 10 CSS Features you should know and use in 2023.
    I was surprised, that we only got 3 points in common... 😲
    And as usual: Great Intro 😄👍 Keep it up buddy!

  • @davidvideauortega287
    @davidvideauortega287 2 года назад +1

    This video is AMAZING. So many cool tricks! I think I need more of these kind of videos.

  • @cmyk8964
    @cmyk8964 Год назад +4

    The object-fit property can also be used to shrink the image in its box, so that all of the image can be visible without aspect ratio distortion!

    • @oa2766
      @oa2766 6 месяцев назад

      How

  • @TomasMisura
    @TomasMisura 11 месяцев назад

    Thank you for this video and that very useful tips! From this list I know only gap and have learned using it as much as possible. liked and subscribed!

  • @perioni
    @perioni Год назад

    these are really helpful. ill save this video for a time in need. thanks bro.

  • @makubex9087
    @makubex9087 2 года назад

    It really worked for me after I look and try some tutorials, yours is the one that worked. Owe you a lot.

  • @sandrachiamaka
    @sandrachiamaka 2 года назад +35

    Nice compilation 👍
    Also, Number 9: Object-fit can also be achieved with
    .box {
    background-image:url(car.png);
    background-size: cover;
    }
    Same as object fit, it covers the width and height of its parent element.

    • @dennisperremans
      @dennisperremans 2 года назад +12

      That's true, but the issue in your case is that you can't add an alt attribute to the image because it's a background image.

    • @NIKENKO
      @NIKENKO 2 года назад +3

      true, but a lot of times you work with websites where you cant just replace img with background, and in that case, object-fit is godsent

    • @SirZyPA
      @SirZyPA Год назад +5

      in most cases you wanna avoid background image if possible, since you cant add alt text, so if people are using accessibility options like a narrator, and your image is there to add context, youre making your website less usable for people with certain accessibility needs.
      background image is fine for things like gradients or other purely cosmetic images, but once they have a functional reason to be there, you wanna use the img element so that people who needs accessibility options, can also get context from them.

    • @edosegheosamagbe9077
      @edosegheosamagbe9077 Год назад

      @@SirZyPA that's something I'll have to keep in mind always. Thank you.

  • @zakidz6716
    @zakidz6716 2 года назад +5

    you can use transform values without transform
    example:
    scale: -1;
    rotate: 180deg;
    .
    .
    .

    • @siema32
      @siema32 2 года назад +1

      this is supported by chrome only for now

    • @zakidz6716
      @zakidz6716 2 года назад

      @@siema32 yes, i hope it will be supported from all browsers sooner because it's so helpfull

  • @JabieSorenson
    @JabieSorenson Год назад

    I love the last part with the gradient animation text im gonna have to steal that idea my friend great work

  • @eneshamzaj328
    @eneshamzaj328 2 года назад +102

    Instead of using pointer-events: none; to get rid of user selection,
    You can use user-select: none;
    ps:
    Thank You, for your Amazing work Ed.

    • @RexGalilae
      @RexGalilae 2 года назад +17

      pointer-events also gets rid of other cursor actions like hover, right click, etc

    • @RexGalilae
      @RexGalilae 2 года назад

      @@darom_96
      Wouldn't that hide the text though?

    • @9463-g1j
      @9463-g1j 2 года назад

      Also only needs setting on a parent div to get rid of selection on all child divs. Seen people who put it on everything, no need to bloat your code

    • @maganopigadus
      @maganopigadus 2 года назад

      Or even better, both.

    • @hype-king3193
      @hype-king3193 Год назад

      also "cursor: default"

  • @Alex-xe6bl
    @Alex-xe6bl 2 года назад +6

    Just to add on number 9: Object-fit is best used with object-position

  • @MaxJacobson1
    @MaxJacobson1 2 года назад +4

    If you want to use semantic HTML for a button, but you don't want all the browsers to add the default styling for it, just do all: unset; and it will reset all the default styling, no matter the element.

  • @obaro-q1m
    @obaro-q1m 9 месяцев назад

    I love how natural you are in your video
    you have my sub

  • @obed.raimundo
    @obed.raimundo Год назад

    Love these!
    I've used a good few of these but the other ones are new to me. Thanks for these!!

  • @eugeneponomarov7429
    @eugeneponomarov7429 4 месяца назад +1

    If you want to get rid of selection then you can use "user-select: none", but using "pointer-events: none" is not a good idea since you may need to capture the click event on that node in the future.

  • @protopan7722
    @protopan7722 2 года назад

    love the new video quality man!!!

  • @keokawasaki7833
    @keokawasaki7833 2 года назад +6

    with pointer-events: none you are suppressing all the events on that element. So the element exists there but no click events or mousemove events are triggered in Javascript. This makes it super handy when creating an overlay that covers the entire page, cuz the events can pass through when the overlay is inactive

    • @Voldrog
      @Voldrog 2 года назад

      Using pointer-events to make an item non-interactive is a bit... Well I'd say it's not the best approach. You should handle your event logic in js, exclude an element from it. Mixing CSS into the logic of interaction seems to me like a workaround.

    • @zebcode
      @zebcode 4 месяца назад

      Thank you, I was wondering what the difference between pointer events and user-select: none; was.

  • @AlexUnderCMYK
    @AlexUnderCMYK 2 года назад

    Knew them all but had a great time anyway! Subscribed!

  • @MaronsCreative
    @MaronsCreative Год назад

    Great Job 👏 I like your style, you are unique!

  • @MadQuakerOne
    @MadQuakerOne 9 месяцев назад

    What actually disable selection is user-select property. Pointer-events property is disable any pointer interaction for this DOM node - hover, click, drag, etc - so you pointer can 'hover' over elements which lay below element with this property. But user-select simply disallow you to select text/image from selecting it on the page and still blocks 'hover'ing elements below it.

  • @KadenAE
    @KadenAE 2 года назад +1

    In addition to the resize thing, you can set a min-width/min-height and a max-width/max-height to set boundries

  • @kw9186
    @kw9186 2 года назад +7

    Great video! Could I ask, what was the vscode extension you were using that showed all the parameters for the animation property (timing-function, etc)

    • @oriel-elkabets
      @oriel-elkabets 2 года назад +3

      It wasn't an extension,
      If you use the auto complete for the animation property it will write all the option as placeholder

  • @KrisHoja
    @KrisHoja 2 года назад +1

    Super cool video - please do more of these!

  • @dron..4898
    @dron..4898 2 года назад +2

    Resize both can be used to open something. If u have a container position fixed with a lower z-index you can resize both a small div with and arrow and once you resize it you can see hidden text or something

    • @Mathhead2000
      @Mathhead2000 10 месяцев назад

      This effect sounds really cool, but I'm not sure I understand how to do it from your description. You are saying something is hiding behind the background but gets revealed when you resize the foreground box on top of it?

  • @stephanmoolman328
    @stephanmoolman328 2 года назад

    I keep coming back to this video, awesome tips

  • @RyuPlaying
    @RyuPlaying 2 года назад +1

    My favourite css trick for making unique css is watching your videos XD

  • @chhavimanichoubey9437
    @chhavimanichoubey9437 2 года назад +1

    you are becoming more comedic and sarcastic which is great.

  • @cosmo-rodrigues
    @cosmo-rodrigues 10 месяцев назад

    There is no word better than AWESOME to describe this video. Thank you so much for sharing so amazing knowledge.

  • @caolanfanning7261
    @caolanfanning7261 2 года назад +1

    Unreal! Thanks King Edward of Development IV

  • @jaidendechon7960
    @jaidendechon7960 2 года назад

    Great stuff! Thanks for making this!

  • @djs1258
    @djs1258 2 года назад +1

    Man, Ed been long time watching back your course videos..... Good to see the excitement and cool work of yours continuing consistently

  • @angel-pu7su
    @angel-pu7su 2 года назад +1

    I love your ever happy vibe. Great video too.

  • @kurdi_x5842
    @kurdi_x5842 2 года назад +2

    you have been so useful during my html learning

  • @FaizanAnwerAli
    @FaizanAnwerAli 2 года назад

    I knew everything except scroll snap. Glad I watched it.

  • @sasagasparovic9351
    @sasagasparovic9351 10 месяцев назад

    Very simple, very short and very usefull, I Like it.

  • @DiogoLScarmagnani
    @DiogoLScarmagnani Год назад

    Very good tips, thank you for sharing this kind of knowledge.

  • @sahiraahamed
    @sahiraahamed 2 года назад

    Very nice... Something new I learned today.. 👍Thanks a lot sir😊just ultimate👏

  • @richardwilliamsmusic
    @richardwilliamsmusic Год назад

    when you type in animation at 12:01 then it shows the parameters you can potentially type in . What extension does that?

  • @hajimeippo804
    @hajimeippo804 10 месяцев назад

    This is so useful, thank you very much!

  • @madsteeez
    @madsteeez 2 года назад

    Your positive energy is uplifting

  • @GarfieLD-Mami
    @GarfieLD-Mami 8 месяцев назад

    Thank you Ed, I am close to become front end developer. 💥💥💥

  • @DanielColeman-ct8qu
    @DanielColeman-ct8qu Год назад

    i thought you would have added "columns" to this list. extremely useful piece of code to get an "insta" layout.

  • @jahirnoriega6103
    @jahirnoriega6103 Год назад

    Man love the videos keep going ❤💪🏽

  • @JIu4Ho
    @JIu4Ho 2 года назад

    Just started learning front-end on bootcamp and this video is so cool and makes me wanna use all these tricks

  • @Rocatagliata25
    @Rocatagliata25 2 года назад +1

    12:07 What's the extension used to get that previous instructions/recomendations?

  • @ebrelus7687
    @ebrelus7687 2 года назад

    Whole lot of cool stuff. Appreciated

  • @Ghulammustafa-wg6cy
    @Ghulammustafa-wg6cy 2 года назад

    Very helpful video.
    Thank you🥰!

  • @BenDemeyere
    @BenDemeyere 10 месяцев назад

    Found some new ones here, great tips!

  • @Alexandra-ou1gl
    @Alexandra-ou1gl Год назад

    Great content man, you explain everything in a way thats easily understood and show plenty of visuals. My go to source for all things coding related!

  • @tonyross5178
    @tonyross5178 2 года назад

    The one about resizing a box helps me a lot! Thank you!

  • @AlexMSib
    @AlexMSib 2 года назад +1

    Cool video man! I used 3 of these at work today what were the odds 🤣🤣

  • @kuoyulu6714
    @kuoyulu6714 Год назад

    nice tips, useful and to the point, thanks!

    • @lukas.webdev
      @lukas.webdev Год назад

      If you want to get to know more great CSS Features: Just yesterday I also posted a video about the Top 10 CSS Features you should know and use in 2023 ... 😉

  • @adityakashyap9318
    @adityakashyap9318 2 года назад

    great stuff dude and as you said in starting : I used 90% tricks shown in this video. I thaght that I know nothing but after thi video I have a good feeling that i am not a bad coder . Inshort you give me my confidence back. otherwise people always bully me that I know nothing much but many time I saved thier work by using such tricks. yet they did not acknowledge me and I was feeling like a looser. But you boost up my moraaaaaaal dude 👍

  • @ArifBillahOnGoogle
    @ArifBillahOnGoogle 2 года назад

    Really cool stuff. Thank you very much!

  • @srsh12345
    @srsh12345 Год назад

    Really cool tips. Thanks.

  • @paulmathew1214
    @paulmathew1214 2 года назад

    Thanks! The text gradient styling is super cool. I already found a use for it!

  • @ΓιωργοςΤζαμας
    @ΓιωργοςΤζαμας 2 года назад

    This was so helpful!! Thank you

  • @jeronimoramalho1218
    @jeronimoramalho1218 2 года назад

    Really cool, I haven't known any of these!

  • @alejandrosantiagomanriquen123
    @alejandrosantiagomanriquen123 2 года назад

    My favorite one liner would be
    white-space: nowrap;
    It prevents text from wrapping to the container size, and is very useful with titles

  • @NNNedlog
    @NNNedlog 2 года назад +2

    Hello dev Ed! I really enjoyed your react portfolio website course with TailwindCSS. I'm almost done with mine and I'm so glad I found your videos

  • @NiceChange
    @NiceChange Год назад

    This is such a great resource. Cheers

  • @jcnation5393
    @jcnation5393 Год назад

    I was thinking of watching flex tutorial, just to add the gap, but this video saved my time

  • @nyctophillia2292
    @nyctophillia2292 Год назад

    Truncate is awesome!! i was implementing it with react(js) before now i'll do it css Thanks Ed

  • @baconchaney
    @baconchaney 2 года назад

    Can't believe I didn't know about flex-gap! Very helpful and honestly would have saved me lots of frustration

  • @snehabhamare09
    @snehabhamare09 Год назад

    Very useful and cool stuff..thank you so much

  • @Thachosenone40
    @Thachosenone40 2 года назад

    Hey Ed how are you doing? Thank you for another great video!

  • @moeinzidehsaraei8738
    @moeinzidehsaraei8738 Год назад +1

    That's great
    thank you

  • @fatimahkhan9367
    @fatimahkhan9367 Год назад

    This is really helpful
    Thanks Guy

  • @Mport-UK
    @Mport-UK 2 года назад

    Good video mate as per!
    The only one I didn't know was Text Gradients. Only ever used as a background Image.

  • @andrewiglinski148
    @andrewiglinski148 2 года назад

    Grid min-max auto fill! I can’t remember the exact syntax off the top of my head but I have it saved as a template… perfectly responsive even grid columns every time!

  • @ekoneko6958
    @ekoneko6958 9 месяцев назад

    Gap is one of the things I learned about early on with Grid, so I just used it with Flex as well and it worked. Yes I used Grid before Flex lol :)

  • @angelmiller3757
    @angelmiller3757 2 года назад

    Really good video and very good explanation! 👍✨