- 20
- 39 624
Dmitry Mayorov
Canada
Приєднався 5 січ 2024
Subscribe for easy to follow web tutorials, and more! 🚀
The Next Big Thing in CSS: margin-trim!
Managing space in CSS will soon get easier with the new margin-trim property, already available in Safari. In this video, we dive into how margin-trim simplifies CSS space management and compare it with traditional methods like the :first-child() and :not() pseudo-classes, and the famous lobotomized owl selector.
Learn why margin-trim is a game-changer for keeping your CSS clean and maintainable. I'll walk you through a problem it solves first, explore various existing solutions, and show you a neat demo using margin-trim at the end.
0:00 - Introduction
00:12 - The Problem It Solves
00:29 - Existing Solution: :first-child()
00:44 - Existing Solution: :not()
00:56 - Existing Solution: Lobotomized Owl
01:17 - The Owl Is Likely Dead
01:32 - Enter margin-trim
01:59 - Demo
02:56 - Browser Support
Get updates about new videos in your inbox → tinyurl.com/yuu8x8my
Follow me on Twitter: dmtrmrv
Learn why margin-trim is a game-changer for keeping your CSS clean and maintainable. I'll walk you through a problem it solves first, explore various existing solutions, and show you a neat demo using margin-trim at the end.
0:00 - Introduction
00:12 - The Problem It Solves
00:29 - Existing Solution: :first-child()
00:44 - Existing Solution: :not()
00:56 - Existing Solution: Lobotomized Owl
01:17 - The Owl Is Likely Dead
01:32 - Enter margin-trim
01:59 - Demo
02:56 - Browser Support
Get updates about new videos in your inbox → tinyurl.com/yuu8x8my
Follow me on Twitter: dmtrmrv
Переглядів: 696
Відео
Master CSS Spacing: Margin, Padding, and Gap Explained
Переглядів 40516 годин тому
In one of my videos, I said, 'Never use margins on reusable components!' Some of you asked, 'How do you create space then?' This video answers that. Plus, I'll break down how to choose between margin, padding, and gap in CSS with a real-world example - It's not always straightforward. Let's dive in! CodePen Before: codepen.io/dmtrmrv/pen/GRajVRx CodePen After: codepen.io/dmtrmrv/pen/rNgjmPp Mar...
This One Thing Causes Most CSS Issues! (learn how to avoid it)
Переглядів 2,2 тис.28 днів тому
In this video, I discuss a common issue where engineers unintentionally "do too much," leading to problems in CSS. We review several examples, starting with a common method to center content using CSS shorthand. This technique often sets vertical margins to zero, which can cause problems if other rules need to apply vertical margins to that element. Next, we examine the "background" shorthand p...
Make Sense of Box-Sizing in CSS (and avoid this major mistake!)
Переглядів 832Місяць тому
Get updates about new videos in your inbox → tinyurl.com/yuu8x8my In this video, we're going to take a close look at the 'box-sizing' property in CSS. We'll cover how it functions, the options you have, and a major mistake you'll want to avoid. Make sure you watch all the way to the end. The 'box-sizing' property controls the box model, or in simpler language - how the dimensions of an element ...
Why I'm Not in My Studio? (A Channel Update)
Переглядів 300Місяць тому
In this video, I'd like to take a short break from my usual content to provide a quick channel update. I'll share what you can expect in the coming months and explain what happened to my beautiful studio with all the lights, the purple backdrop, Walter the plant, and the Rage Against the Machine poster. Subscribe to know when the new videos are up and to learn when the free web-app mini-course ...
Refactoring Old CSS with AI!
Переглядів 1,1 тис.Місяць тому
In this video, I discuss an interesting case study on how I successfully refactored a substantial amount of old CSS using AI. We explore how you can start using AI today to tackle tedious tasks and enhance your productivity. I explain how I refactored numerous Sass variables into CSS custom properties and adjusted the root font size from 10px to 16px, completing in a few hours what would manual...
Flex-Grow vs Auto Margins: Which Wins?
Переглядів 7192 місяці тому
In one of my previous videos, we explored how to align flex items using auto margins. Since then, I've received several questions under that video asking why not use "flex-grow" instead. So, I've decided to create a short follow-up video explaining the differences. CodePen used in the video: codepen.io/dmtrmrv/pen/xxBPowg Chapters: 00:00 - Introduction 00:20 - Recap of the Previous Video 01:07 ...
Master CSS Units: Pixels, REMs, & EMs
Переглядів 1,1 тис.2 місяці тому
In this video, we'll explore three essential CSS units: pixels, rems, and ems, focusing on when and how to best apply them. But Instead of simply saying 'use pixels here, rems there, and ems in another place,' my goal is to clarify how these units operate so you're better equipped to make informed decisions in your own projects. I'll also share some tips to streamline your calculations for rem ...
Is Mobile-First Design Still Relevant in 2024?
Переглядів 1,8 тис.2 місяці тому
Is a mobile-first approach still important in 2024? Let's break it down. In this video, I discuss what mobile-first means and whether following this approach is worthwhile. We explore mobile-first through the lenses of content, visual design, accessibility, and engineering, including tips on HTML and CSS. Chapters: 00:00 - Introduction 00:25 - Mobile-First Is Not Just About Min-Width Media Quer...
Create a Sticky Header with HTML & CSS: A Step-by-Step Tutorial
Переглядів 1,3 тис.2 місяці тому
Learn how to create a sticky header that adjusts its height and seamlessly integrates with internal links. This video explains the implementation of a sticky header using HTML, CSS, and a bit of JavaScript, showing how to maintain the header's flexibility and accessibility as you add more content. Demo: codepen.io/dmtrmrv/pen/xxeEGbg Chapters: 00:00 - Intro 00:11 - HTML & CSS Basics 00:44 - Mak...
Keep Footer at the Bottom of the Page: HTML & CSS (2024)
Переглядів 2,8 тис.3 місяці тому
Keep the footer at the bottom of the page, even on pages with minimal content. In this video, we tackle the popular layout challenge of keeping the footer at the bottom of the page, using CSS grid and dynamic viewport units for a sturdy solution, especially on mobile devices where the page height can vary as users scroll. CodePen: codepen.io/dmtrmrv/pen/NWmxbPx Chapters: 00:00 - Introduction 00...
Learn CSS BEM (and avoid these common mistakes)
Переглядів 4,6 тис.3 місяці тому
In this video, we're diving into BEM, which stands for Block Element Modifier-a popular semantic CSS methodology. We'll break down the basics of BEM, including blocks, elements, and modifiers, and show you how they all work together. Plus, we'll cover some of the common questions people have and highlight mistakes to avoid. CodePen: codepen.io/dmtrmrv/pen/vYMEGpx Chapters: 00:00 - Intro 00:14 -...
CSS Subgrid Layouts Are Here!
Переглядів 6 тис.3 місяці тому
In this video, we'll explore together how to use CSS Subgrid for a popular layout: a newsletter sign-up form where everything aligns side by side, and the submit button lines up perfectly with the input fields. This setup can get a bit tricky, especially with the addition of labels and changing help text for the input fields. Previously, achieving such layouts often required JavaScript. But now...
Learn This Flexbox Item Alignment Trick!
Переглядів 13 тис.3 місяці тому
Head's Up: some of you asked why I haven't used flex-grow in this layout. I answered that in this video: ua-cam.com/video/yLjZO3W9WXw/v-deo.html In this video, we're taking a closer look at how auto margins work in Flexbox and why they're extremely useful. Auto margins in Flexbox allow us to manage the space around items in a flexible layout effectively. This feature is especially useful for gr...
Fix Unequal Columns in CSS Grid
Переглядів 1,5 тис.4 місяці тому
Having trouble with CSS Grid because your columns aren't equal? You're not alone. This video explains why columns using 1fr might not always be the same size and offers easy fixes to make sure your grids work properly. We use a simple example: building a grid for a donut shop website. Sometimes, when you change the content, the columns get all mixed up in size. This isn't a mistake; it's just h...
Rebuilding a Logo Grid on Michelin's Guide Website with HTML & CSS
Переглядів 5494 місяці тому
Rebuilding a Logo Grid on Michelin's Guide Website with HTML & CSS
Any particular reason why you wouldn't just use flex or grid with the gap property to achieve this same thing?
Hey @Dorchwoods, thanks for the question! Using gap is a valid approach, but sometimes it's just not enough. Imagine creating a vertical rhythm inside an article component; you might want different spacing between elements within the same container. I talk more about gap vs. margin in a previous video. Check it out starting at 7:28. Let me know if this answers your question!
You're the one who improved my CSS writing skills, literally feeling that finding your channel was the luckiest moment for me. Love from India bro 🇮🇳❤
Thank you Soumil, so happy to hear that!
Whats the problem with flex+gap solution? jsfiddle: osnw3g8u
That's a perfectly valid approach; the gap solves this issue too. However, there are cases where it's not enough. For example, when creating a vertical rhythm in an article, you might want different spacing between elements inside the same container. I actually talk more about this in my previous video at 7:28. Hope this answers the question.
Thank you Dimitry! Really like your content. keep up the good work! 🙌
My pleasure! Thank you for the comment!
Damn your english is so good
Thank you
Thanks bro💯 Keep up the good work
margin-block* and padding-block* etc are new to me 😑
Yeah! Those are logical properties. Very handy
Sorry Dmitry, "site__header site-header". What's with the site-header class? Is this another flavor of BEM? Familiar BEM would have "site--header" for a Modifier as "site__header is correctly the Element's class.
Hey @NedumEze! Great question. I think it is easier to think like this There is a `site` block: site site__header site__main site__footer And three separate blocks: `site-header`, `site-main`, `site-footer`. The first one acts as a container, like a box that holds actual `site-header`, `site-main`, `site-footer` blocks or other elements. It's perfectly fine to set margins on `site__header`, `site__main`, `site__footer` because they aren't used on their own outside of `site`. I talk more about it in this video too: ua-cam.com/video/Quxd5iNEp-4/v-deo.html I know it may be a bit confusing at first, but this structure is very robust. It allows for easy swapping of components inside the header, main and footer while keeping spacing consistent. Let me know if this answers your question!
@@dmtrmrv Thanks @dmtrmrv. It does. I appreciate.
@NedumEze you are welcome!
real world examples, not just isolated demos are so so so helpful! Thank you!
Glad it was helpful!
Thank you, it helped to solve my problem!
Nice one bro
Thank you!
Доступным английским объясняешь, даже сабы врубать не приходится ) Кроме верстки планируешь что-то ? js, фреймворки,метафреймворки, сборщики и т.д
Спасибо! Да, это все в планах. Я подробнее в этом видео рассказал: ua-cam.com/video/6w0TJnNvBYA/v-deo.html
Im confused when we need to create a block and we dont need to because sometime i really dont know if i will reuse this element again or not Second question im still confused about combine between utility class and bem blocks
@GameOver-db7wg Thank you for the question! I'd be happy to look at your code to provide more specific guidance, but here are my thoughts on creating a block vs. an element. If an element has a distinct role in your interface, it's a candidate for a block. Even if you're unsure about reuse, it's better, in my opinion, to have more blocks than fewer. This approach helps avoid the issue of complex blocks that we discussed towards the end of the video (14:22). Regarding utility classes, .visually-hidden is a great example. In my projects, I also use utility classes like h1, h2, h3 to style other text elements to visually resemble these headings. The key is consistency. Consider how consistent you can be with these classes. Are they truly atomic? Can you keep reusing them effectively? Again, I'm happy to look at your code to give a more detailed answer.
You mention "don't use margins on blocks" fine but did not show us the alternatives. Would it be to use Flexbox or grid spacing properties like Gap etc? Or is there some padding trick?
@EyeIn_The_Sky Thanks for the question! You are actually not the first one to ask. I see how this part of the video can be a bit confusing. In short, it depends, but you are right. Gap is one of the tools, another is setting the margins using rules like .container > * + * { margin-block-start: Xrem; } which adds margin to all children except the first one. I have a video about exactly that coming in the next few days, so stay tuned!
Thanks Dmitry! All those details wonderfull and great to understand. Your level of details and speed is great to listen to.
Thank you, Rick! Appreciate your kind words!
NOT an issue, its a feature, thank you come back soon
Famous words! It's a feature!™
I can tell from the way you speak that you are very passionate about the things you are talking about and you are also very eager to share your knowledge. Your explanations are crystal clear and its very easy to listen to you. Most importantly, you sound very authentic. Please keep the same format and let content speak for itself. UA-cam can be a very hard grind, i started a channel that blew up overnight but its just too much work if you have other more pressing responsibilities. The point I am trying to make, you can bring a lot of value to a lot of people. Many focus on the subscribers through click bait titles and not the content. I watched every video on your channel today and i found it absolutely randomly. That should tell you, you can be as successful as you want to be on here because you have the right formula and at the same time help a lot of people. It just needsto be worth it to you. Looking forward to more content and thank you! P.S Sorry for the long post, I got the feeling you were looking for some feedback. I am in the process of switching careers now and doing the self taught route, that makes me relate to you even more. Love what you said about never stop learning. It really is one of the hacks to self fulfillment. Hopefully this long post will help the algorithm.
@Deekay909 Thank you for the kind words and for taking the time to write this comment! I truly appreciate the feedback and encouragement. It's definitely a grind, but comments like yours make it all worthwhile-not the likes or the number of subscribers. I wish you all the best with learning the ropes. It takes time, but it is a rewarding vocation. If there's something specific you're struggling with, let me know! I'd be more than happy to cover it in a video.
@@dmtrmrv Now that you mentioned it, maybe you can make a quick/short video on what to focus on outside of css/js? With the amount of technology that is out there, its hard to management sometimes what to study next. Iv been working on html/css/javascript and React. From what I understand, Typescript is industry standard at this point. Do I study Typescript next or should i look into Next.js for React? Basically, what is your opinion on the libraries/frameworks to focus on that you use the most in the industry, outside of fundamentals, in order to be well rounded. Continue to get better and studying vanilla css/js will never stop, goes without staying. Thank you.
Great video! Very useful!
Thank you!
Nice job, Dmitry. I just want you to check an alternative CSS-only solution. The CSS Grid line names can solve this same problem. Although it comes with a bit of more codes, it's more scalable.
Hey @jelilabudu! Thanks for the comment, I'd be curious to see your solution. Do you have it in a CodePen or somewhere else?
Thanks Dmitry! This has given me a lot of ideas where I could be more thoughtful when writing CSS :)
Thank you! Great to hear!
Super! I can understand your css-html pain. Thanks for margin-inline.
Glad the video was helpful!
Refreshing to see a real world developer talking through how to think about css and html. Your videos are super helpful!
Thank you! I'm glad the videos are helpful! Yeah, I believe understanding HTML and CSS is important, it makes working with frameworks easier.
Great lesson Dmitry. I wonder how many coders were wishing they had seen this earlier.
Yeah, true. I definitely made this for my younger, junior self.
Thank you Dmitry for another great lesson. I have certainly been guilty of exactly this.
Glad it was helpful! I've been guilty of this myself-no shame in that. We're all learning, and that's what's most important.
Your videos are very helpful, thanks!
Glad to hear that! You are welcome!
Thanks a lot for your amazing CSS tutorials!
You are most welcome!
Nada como CSS do BEM
Extremely helpful, especially your code pen. I'm curious how you approach a larger project using Utopia. Huge thanks!
@bls512, thanks! I'm glad you found the CodePen useful. Good question! I honestly think Utopia is just a tool (a great one though). What's important when using it on larger projects is ensuring the team is on the same page about how to use it. And generally, for large projects, clear communication with your team is crucial. This includes having straightforward guidelines, clear commit messages, PR descriptions, good documentation, and keeping everyone updated.
I learned html css and js. Now i am learning backend but the point is i cannot make Good looking layout specially i stuck in responsiveness Anyone any Suggestion?
Hey @gaming_with_raza7867, thanks for your question! Honestly, there’s no easy answer to this, but I’ll try to respond to the best of my knowledge. In short, it’s a journey-there’s always something new to learn, especially in Front-end development. I also struggle with responsiveness sometimes, particularly with complex components or unclear guidelines. What usually helps is working your way from mobile up. Build your projects as if desktop doesn’t exist, then add layers of styles for larger viewports. Use implicit grids and clamp to avoid relying too heavily on media queries. In general, learn typography. The web is mostly text, and knowing how to represent textual information well can help a lot. Try to approach every project as a system rather than a one-off thing, and you’ll improve over time. Trust the process. Hope this helps!
Thanks! This is insanely important stuff. And you explain it so well. You almost make css make sense!
Thank you : ) I swear it does! Well, most of the times.
Nice lesson!
Glad you enjoyed it!
Thank you so much! Your explanation is so clear and I never knew that trick! Thank you!
Thank you!!! Again another great explanation!
My pleasure! Glad you found it helpful!
Hi, I have been really enjoying your teaching style and look forward to your new videos. I have recently been learning about partials folders in Sass and learned about creating variables in a colors folder for example. I realize that isn't what you've done here as you've listed colours at the top under the :root tag?... not sure.. maybe in a future video could you talk about when to use this list of colours that you have listed in double hyphens vs using partials folders and using $black = #000000, with the dollar symbol, for example. Maybe I'm missing something fundamental, not sure, I will also look it up. Thanks!
Hi @MissEAG! Thanks for your kind words and for watching the videos! You're right; I don't use separate files to store variables in my demos and stick to vanilla CSS rather than Sass. My main goal is to focus on a specific topic or pattern that can be applied across various contexts-CSS, Sass, CSS-in-JS, and so on-rather than on the tooling itself. In real-life projects, it often depends on the project, but I would likely put variables into a separate file, which is generally considered a best practice. Regarding Sass, I stopped using it a few years ago as CSS began to rapidly evolve. We now have features like variables, nesting, and other enhancements, so I personally don't see the need for Sass since it adds another tool and dependency. I prefer to keep my projects as dependency-free as possible (but with as many as necessary). However, I understand some engineers still use Sass, and if it works well for the project and the team, that's perfectly fine. Perhaps a CSS vs. Sass video is something to consider for the future.
Great solution and approach to the subject! The way you explain that is just perfect! You just won a new subscriber to the channel! Thank you for the excellent and helpful video! Greatings from Brazil!
@alexmacol228 Thank you, Alex! Welcome aboard, glad you are enjoying the videos!
as always explain for humans ;) cant wait for more!
Thank you! Glad to hear the explanation was easy to understand!
that "OMG" reaction to the text-input's width was absolutely epic! 😎✌
Well, that was genuinely how I felt when I first started learning CSS, lol!
@@dmtrmrv so true, i still get surprised with how some styles work, even after im 100% sure its correct 😅 then, i find my own idiotic mistake 😁
How to make font-family inherit for form elements if it is set in body?
Hey @onelook1870, thanks for your comment! I'm not sure I fully understand the question. The video doesn't cover that, but I'll happily look at your code if you happen to have it on CodePen or Github.
Form input field doesn't inherit font family set to body. We have to set again. body { font-family: "Poppins", sans-serif; } We have to set it again for form fields.
@@onelook1870 That seems to be right, but let's wait for Dmitry confirmation. Thanks for the input (no pun intended). 🙂
5:00 2rem should be equal to that of .pixel, but why is that html that is 16pixel by default changes and not .pixel?
@vertigoz Not sure I fully understand the question 🤔
@@dmtrmrv I was thinking regarding zoom, when you zoom it all scales up. ps- I tried this on codepen: html{font-size:16px;} h1{font-size:2rem;} h1.test{font-size:32px} one p, one h1, and one h1.test they all scale up if I choose to zoom, if I change font-size they remain the same
@vertigoz Oh I see, so zoom feature works a bit differently. It just scales everything. These changes also do not always carry over between the sites. Font size, on the other hand only affects the font size and those changes are global to all sites you open in the same browser. Does that answer your question?
@@dmtrmrv Yes, thanks! :)
I still don't understand why there's no babana for scale...
Maybe we can propose 1bbs (one big banana scale) for those really large elements.
Keep up the great work Dmitry, love your pace and articulation 🙌🏻 - have a splendid day
Thank you! 🙌
Hi Dima, we met at GitHub Universe last year. Your channel is going awesome and I’m a fan!
Hey James @jamesreagan4179! Happy to see you here! Glad you are enjoying the videos, hope we get to catch up at the next Universe. not sure why UA-cam hasn't showed me this comment :((
Can't wait for new videos ❤
Coming very soon!
Oh my god! I'm looking for this video for a while ! Very very interesting and well explained! I thank you a lot!
Thank you! Glad it was helpful!
I'm in for all of your ideas, Dima!
For me, your ideas for development channel are great. There aren't many materials like yours. I really like how you explain concepts and focus on fundamentals. Also, you have your own style, you don't pretend anyone, and you're authentic, which is why your videos are enjoyable to watch. I wish you all the best.
Thank you for the kind words! 😊
Nice. Thank you. Do have a video to solve the problem when the flex direction and the grow direction you need are different, and height:full or width:full aren’t a solution viable because the father element hasn’t defined dimension?
Hey @jonasgpayer, do you have a CodePen or something like that I can look at?
Fantastic channel, Dima. Clear and concise. You're a great addition to the UA-cam dev community. I've been a full-stack dev for a long time (PHP, JS, CSS, WordPress, _finally_ getting into React) and your videos almost always teach me something I didn't know.
Thank you! I'm glad to hear you enjoy the videos. React is a lot of fun-I really like it!
Good stuff, looking forward!
🤩 sounds good. Web App - Super Cool idea! Responsive Navigation - Yes please! Lately I dealt a bit with accessibility standards, for example: - Focus state for keyboard users. - Color decisions for Color-blind people. - Proper Semantic for Screen readers. and so on. I have some beginner questions on this topic, so maybe this could also be an idea for future Videos. Some websites do a focus around the burger menu (mobile) when clicked. This looks ugly but seems right due to accessibility standards for the keyboard. Is there a way that focus only applys by keyboard and not by mouse? I'm just beginning to understand accessibility and wonder what's the best way to handle this.
Thanks for your comment! Yes, those are great topics and not very straightforward. I'll definitely cover them!