Stop fixed navigations covering content on scroll

  Рет қаралды 117,837

Kevin Powell

Kevin Powell

Күн бұрын

Пікірлер: 227
@KevinPowell
@KevinPowell 2 жыл бұрын
I got early-access to a new thing YT is trialing for multi-lingual videos! If you speak Spanish, you can click the settings cog and there is an "audio track" option, with a Spanish audio track. Would love feedback on the quality of it!
@plexor-dev
@plexor-dev 2 жыл бұрын
Jajaja cool, that is amazing.
@QwDragon
@QwDragon 2 жыл бұрын
How have you made it? Just recorded video in one language and then add audio for another one? Or you can have different videos inside of one? I'm interested in making RU/EN videos :)
@plexor-dev
@plexor-dev 2 жыл бұрын
KZbin app added everything in Spanish from the title to the voice I was very surprised to hear it, it seems native Spanish
@KevinPowell
@KevinPowell 2 жыл бұрын
@@QwDragon I'm not entirely sure how it works tbh 😅 - I got invited to trial a new service called Aloud. In the end, they provide you with a single video that has multiple audio tracks to upload to KZbin. I don't know how it encodes the tracks to know the different languages for YT though... aloud.area120.google.com/
@QwDragon
@QwDragon 2 жыл бұрын
@@KevinPowell thanks, that's what I wanted to know - single video track and multiple audio. Very cool feature, but I expect comments in mixed languages to be a bit messy)
@MrMairu555
@MrMairu555 2 жыл бұрын
Others have said it before... now it's my turn... You're a mind reader! Have this exact issue that I've been trying to deal with the last couple of days! Been using a padding/negative padding hack, but it's "magic numbers" and a complete pain in the backside that way! This looks perfect and simple! Thank you!
@frittex
@frittex 2 жыл бұрын
I can't believe I wasted ~2hours on it, and actually, it's so easy. You're a life saver Kevin, thank you!
@bxrclxys
@bxrclxys 2 жыл бұрын
This is the exact problem I was having just yesterday and have managed to stumble upon this video a day later. Thank you very much Kevin, much appreciated for the consistent, helpful content!
@asyncawaited
@asyncawaited 2 жыл бұрын
You're an absolute beast. I've seen a few of your videos now and your knowledge of CSS has been helpful to me putting together this frontend. You've earned a sub.
@Lazy4444
@Lazy4444 2 жыл бұрын
Damn it scares the sht outta me when the video start and there was a voice over speaking spanish xD At first I tought that someone was reuploading your videos with spanish audio. My native language is spanish, but I still prefer to watch videos on english, specially when they have clear pronounciation like you
@MrMudbill
@MrMudbill 2 жыл бұрын
I suppose it may be worth noting that aside from devs, users who are more likely to actually "resize" the window are those on mobile devices switching between portrait and landscape orientation. So if that causes a change to the layout, a ResizeObserver might be more relevant.
@juanecheverry9055
@juanecheverry9055 2 жыл бұрын
The Spanish version sounds amazing! I will personally continue watching your videos in English because I understand both languages and I prefer your human voice over a robot, but I still think it’s pretty impressive that you can have multiple languages in a video like that.
@Elias-zn6og
@Elias-zn6og 2 жыл бұрын
I hear the spanish version too, but I'm learning english and I prefer to learn
@gbagba81
@gbagba81 2 жыл бұрын
Q loco no?
@blackpurple9163
@blackpurple9163 Жыл бұрын
How do you set a different language output? I only see captions but the voice is still English
@juanecheverry9055
@juanecheverry9055 Жыл бұрын
@@blackpurple9163 there’s a video settings button where you can change playback speed, cc, etc The option is called audio track. What device are you using to watch the video?
@blackpurple9163
@blackpurple9163 Жыл бұрын
@@juanecheverry9055 my smartphone, no KZbin app I've tried had this option
@funworld8379
@funworld8379 Жыл бұрын
Thanks Kevin. I was doing a next js react project where I was facing this issue. I tried to think hard and couldn't come up with the solution. This 2 lines of code saved my day . Cheers🥳
@vimalathithand917
@vimalathithand917 Жыл бұрын
Hey kevin you literally are a lifesaver!! Was just searching for this for almost an hour! Thanks a lot!
@nanavybes
@nanavybes 2 жыл бұрын
Exactly what I was looking for 9days ago. Thank you 😊
@dx8pi6o48
@dx8pi6o48 2 жыл бұрын
I had no idea you could dynamically change css variables with javascript!!! That's so awesome! If only I knew this sooner xD
@RogerOnTheRight
@RogerOnTheRight 2 жыл бұрын
You do good work. Straightforward and to the point. All practical stuff.
@विवेकराजपूत
@विवेकराजपूत 10 ай бұрын
This video saved my day. Thanks @kevin
@royjr.bustillo9813
@royjr.bustillo9813 2 жыл бұрын
I have been fixing this problem on my code for like 3 weeks, and i just found the answer here. thanks, bro
@oh-digital
@oh-digital Жыл бұрын
Thanks, i had my scroll-padding-top on the element i was scrolling to rather than the root, saved me lots of time
@pohanggg4589
@pohanggg4589 2 жыл бұрын
OMG I always face a problem like this, ALWAYS. So, usually when this happens, I would just simply set the #section_id to one div above its actual position, so when it scrolls, it would show the whole h2.section-title, but still, it does not feel right every time I do it. Sir, once again, thank you sooo much for helping me understand web programing interface, css, js, etc. Keep making videos, keep inspiring! God bless you, sir.
@ilyes-grine
@ilyes-grine 2 жыл бұрын
THANK YOU , every time a get a problem in this website am working on, i find that you have done a video about it. last time it was the hover in a mobile and this time the nav covering the content.
@austinedwards6334
@austinedwards6334 Жыл бұрын
Perfect! Thank you! I've been racking my brains for 2 days trying to solve this issue!
@Demilada
@Demilada 6 ай бұрын
Thank you for always helping me solve my css issues!😅
@GlowBug1120
@GlowBug1120 2 жыл бұрын
Thank you! Thank you! I was literally looking for a solution to this! So helpful!
@firelop
@firelop 2 жыл бұрын
I used to got the same problem, I fixed that by adding this css code: margin-top: -100px;padding-top: 100px; EXPLAIN: margin-top with negative value will destroy the space that padding-top makes. So it works.
@paulmitchell2916
@paulmitchell2916 2 жыл бұрын
One of the other code tutorial guys uses a trick so the viewer doesn't have to watch and hear typing (and inevitable retyping).. I think he types in all his code and proofreads it, then deletes the bottom line, then the second to bottom line etc.. while shooting the actual video he re-does the lines one by one.. it's slick!
@masterkratos2
@masterkratos2 2 жыл бұрын
WHAT THE!!! I was just searching for this, and here you upload the video about it.
@MuhammadAbbas-bd4kg
@MuhammadAbbas-bd4kg Жыл бұрын
Literally a life saver. Thanks alot Kevin
@fernandoboschiero1178
@fernandoboschiero1178 2 жыл бұрын
Kevin, been learning so much from your videos. Thank you for the content.
@teejasvinibundhoo140
@teejasvinibundhoo140 2 ай бұрын
OH MY GOD! i am new to css and i have wasted an entire day on it thank you so much. u're seriously so awesome
@yawnfranco
@yawnfranco 2 жыл бұрын
Literally perfect timing. Great vid
@brandonsayring
@brandonsayring 2 жыл бұрын
offsetHeight returns an integer value. Using document.querySelector('.primary-navigation').getBoundingClientRect().height will return a float value which will give you the precise height so you dont have to use the hacky -1 solution.
@jonathanmcdermott25
@jonathanmcdermott25 2 жыл бұрын
You are amazing Kevin! Thank you for all of the helpful tips and tricks. :)
@andrasjuhasz.
@andrasjuhasz. Жыл бұрын
A better way to do this without JavaScript: 1. Set up a CSS var for the height of the top navigation, as the height of the element rarely change. 2. Use that variable not just for setting top navigation height, but also for setting scroll padding top. Either directly the number, or using the var as part of a calc() function and adding a few extra pixels on top of the navigation height.
@MatthewMichalsky
@MatthewMichalsky 2 жыл бұрын
Another approach is to have a css variable that would control both the header’s height + the padding offset. Then, you wouldn’t need JavaScript or worry about window resizing
@pepperdayjackpac4521
@pepperdayjackpac4521 2 жыл бұрын
that would work? :o
@sktnml
@sktnml 2 жыл бұрын
can you please explain further?
@uziboozy4540
@uziboozy4540 2 жыл бұрын
@@sktnml doesn't really need more explanation, lol
@oriel-elkabets
@oriel-elkabets 2 жыл бұрын
​@@sktnml :root { --navHeigth: 200px; } .nuv{ height: var(--navHeigth); } html{ scroll-padding-top: var(--navHeigth); } in the root selector you can create css variable the name of the variable start with two hyphen I think the reason Kevin didn't do it, It's because you don't always want to set your navigation height, Sometimes the height comes from the font size, and the padding and so on. In cases like this, you want to use js to get the final height and do the calculation by that
@betanpc8210
@betanpc8210 2 жыл бұрын
@@oriel-elkabets Ty for this friend
@libbeytds
@libbeytds 2 жыл бұрын
I just realized he says "Hello my frontend friends" in his intros, not "friend and friends" lol
@ForgottenGames
@ForgottenGames 2 жыл бұрын
I just opened this video to drop a like because the title was all I needed to agree with
@patelpriyank
@patelpriyank 2 жыл бұрын
Great video! I always used to do a margin-top for each section but this seems much better. Just out of curiosity, doesn't this affect any other scrolling element on the page? I can't think of anything at the moment but would like to keep in mind if this 'breaks' anything.
@TheCrazySoundStudio
@TheCrazySoundStudio 2 жыл бұрын
This way worked! I'm coming here for more CSS tricks.
@ajinkya4658
@ajinkya4658 2 жыл бұрын
thanks kevin, much needed video
@hikari1690
@hikari1690 2 жыл бұрын
Omg! This has bothered me forever cause I always need to hack a solution and am glad to find a css solution ❤️
@elproductorrookie8385
@elproductorrookie8385 2 жыл бұрын
Hi. I solved this problem, configuring a padding-top for the #. It was all due to an oversight, because I thought I was padding-topping my . I'm taking my first html and css lessons. I think that at first it happens to all of us that we do things without knowing.
@frankiefab
@frankiefab 2 жыл бұрын
OMG! I just learnt something new which I'm going to apply on my portfolio website. Thank you for this useful tips.
@nickpapadatos7587
@nickpapadatos7587 2 жыл бұрын
This used to bother me as well - great video, thank you Kevin.
@keshavkishorram7678
@keshavkishorram7678 2 жыл бұрын
You are CSS hero ❤
@universecode1101
@universecode1101 2 жыл бұрын
Css is so important ... Great Kevin 👏🏻
@JackTheZuluman
@JackTheZuluman 2 жыл бұрын
I experienced the same thing with my portfolio. Thanks soo much for this
@marianagulias2711
@marianagulias2711 2 жыл бұрын
Awesome video!! Thank you kevin!
@daleryanaldover6545
@daleryanaldover6545 2 жыл бұрын
I always make my navigation bars at a fixed height, this fixes common annoying css layout shifts and inconsistent re-sizing. By default the anchor placement is on the top left edge of the anchor tag, the way I get around this anchor behaviour is by adding a padding-top to the actual anchor element equal to the navigation bar height. This way I don't need to change scroll offset. If you expect the navigation bar height to change that's when you turn to JavaScript for help.
@AlJapairai
@AlJapairai 2 жыл бұрын
That is actually is going to help me, thank you
@eniolakayode2384
@eniolakayode2384 2 жыл бұрын
You know whats crazy, i was just experiencing this, i thought to use JS and your video pops up.... live saver
@wernayasa
@wernayasa 2 жыл бұрын
Looks promising for my novel theme project. I'm struggle with JS, this help me understand JS little bit.
@JimKernix
@JimKernix 2 жыл бұрын
You could also use Math.ceil() to round up in your JS constant and remove the + 1 or + 5 for the pixel value: const navigationHeight = Math.ceil(document.querySelector('.primary-navigation').offsetHeight);
@utterwokenonsense1995
@utterwokenonsense1995 2 жыл бұрын
You mean Math.floor()
@JimKernix
@JimKernix 2 жыл бұрын
@@utterwokenonsense1995 Oh, I forgot he changed it to -1 - then yes, Math.floor
@mykalimba
@mykalimba 2 жыл бұрын
@@JimKernix The real issue is that the "offsetHeight" property always returns an integer, so it's only moderately representative of the element's _actual_ height.
@dsdsspp7130
@dsdsspp7130 2 жыл бұрын
that just returns offset height itself. ceil and floor of an integer is the integer itself.
@JimKernix
@JimKernix 2 жыл бұрын
@@dsdsspp7130 What's your point? He notated that it was slightly below the actual number so using ceil will "rounds a number up to the next largest integer", floor "returns the largest integer less than or equal to a given number". So by using either of those removes the need to use +1 or -1 to get to the desired number. I'm not familiar with offsetHeight, I was making a suggestion as to an alternate method to arrive at the number he wanted.
@AbdicateDotNet
@AbdicateDotNet 2 жыл бұрын
Awesome video!! Thanks for using a smidgen of JS! :)
@Gui-sector7
@Gui-sector7 2 жыл бұрын
Very interesting ! I used to to make it with scrollIntoView function in js, that helps to scroll at the center on the element. I even tried to create an absolute element and gave him the #id and put him like 50px on top of the article... that's a bit a diy thing 🤣 haha thank you I didn't know the property scroll-padding-top ! I will try this next project !
@downpp2255
@downpp2255 2 жыл бұрын
Haha, wish i saw... wait this video came out now. I was tearing my hair away when trying to find a fix for it.. Thank you
@mohamadybr
@mohamadybr 2 жыл бұрын
I had to create the entire functionality in JS, then I learned about scroll-padding-top. It was a frustrating situation xD
@tumbler9428
@tumbler9428 2 жыл бұрын
I did not know "scroll-padding" yet - thank you
@user-ni7ct5vr8u
@user-ni7ct5vr8u 2 жыл бұрын
Didn't know about scroll-padding. I usually have specific anchors for navigation (a.nav) and then I move them with CSS: a.nav { position: relative; top: 100px }. I will probably start using your solution instead in the future.
@michasosnowski5918
@michasosnowski5918 Жыл бұрын
Thanks, my friend linked me your video and I fixed my problem :)
@doubledeckercouch6251
@doubledeckercouch6251 2 жыл бұрын
Bummer - was hoping to see the window resize/observer fix covered in this video. Maybe in a ‘part two’? Pleaseeeeee :)
@DanielDeight
@DanielDeight Жыл бұрын
Love you Kevin!
@Obikin89
@Obikin89 2 жыл бұрын
I've fixed that issue by setting the height of my navbar in a CSS variable (with rem units so that it's responsive). No JS, and no need for any adjustment at all.
@rasmuslarsen77
@rasmuslarsen77 2 жыл бұрын
I’ve done the same. It works quite well.
@johnntinos1251
@johnntinos1251 2 жыл бұрын
This works only for a specific height navigation bar. So it is responsive on a static height element. Except, if you find all the braking points and use media query in CSS( that have problem in multi language sites).
@mykalimba
@mykalimba 2 жыл бұрын
This is the first solution that I thought of too. I would solve the problem in CSS using custom properties, and not bother with this JavaScript approach.
@alexprofit4937
@alexprofit4937 2 жыл бұрын
Great trick , I love it . Thanks
@victoreleanya4375
@victoreleanya4375 11 ай бұрын
Thanks Kevin🎉
@esprit-critique0.114
@esprit-critique0.114 2 жыл бұрын
i love it , thank you the king 🕺🏿.
@chukwuebukaobiajulu2849
@chukwuebukaobiajulu2849 2 жыл бұрын
This is really awesome
@doctorbrad
@doctorbrad 2 жыл бұрын
I wish I could like this video twice... thank you!
@camilomolina2110
@camilomolina2110 2 жыл бұрын
Esta nueva función de audio traducido al español es genial para todos los latinos que aprendemos a programar gracias a este canal!!
@leo3464
@leo3464 2 жыл бұрын
Vos escuchas como un chirrido de fondo? Es re incomodo
@jornzander1285
@jornzander1285 2 жыл бұрын
Great tip! Thanx!
@lenninpalacios
@lenninpalacios 2 жыл бұрын
Kevin en Español, gracias. Me has ayudado tanto, y ahora en mi idioma!
@8koi245
@8koi245 2 жыл бұрын
Ahhhh I can't believe this! tysm!!
@rayrayaray
@rayrayaray Жыл бұрын
thank you kevin
@bwsince1926
@bwsince1926 2 жыл бұрын
Javascript functions: the bane of my existence. I haven't managed to get into Three.js or similar because even if I know Javascript well-ish, I don't get all the calculations!
@Edu4Dev
@Edu4Dev 6 ай бұрын
You can alse use a ::before pseudo-elemento with blank content and negative margin-top.
@Alex-xf2dd
@Alex-xf2dd 2 жыл бұрын
Thank you!
@HuynhLuong227
@HuynhLuong227 2 жыл бұрын
many thank, you are amazing
@re.liable
@re.liable 2 жыл бұрын
I thought this was going to be a video about those large af navbars in websites nowadays that take nearly half the screen and barely leaving anything for the scrollable content 😂
@supTE
@supTE Жыл бұрын
Thanks for this cool tip.
@supercoolninja
@supercoolninja 2 жыл бұрын
Nice tips !
@Hefss
@Hefss 2 жыл бұрын
Thenks, I didn't know you could change css variables in Javascript
@mochamadsyahrulakbar8850
@mochamadsyahrulakbar8850 2 жыл бұрын
Thank you very much sir
@vohracodes
@vohracodes Жыл бұрын
youre savior thank you so much 😄
@rafaguzowski8104
@rafaguzowski8104 2 жыл бұрын
i love your videos!
@omarnur2269
@omarnur2269 2 жыл бұрын
What a legend
@nocommentaryminecraft4416
@nocommentaryminecraft4416 2 жыл бұрын
For a second I thought you were gonna start rapping 😂😂 5:15 And we write scroll padding Because that's what I'm setting And here I wanna set the value That we're going to be putting
@thanhnn16
@thanhnn16 Жыл бұрын
Thank you so much
@mykalimba
@mykalimba 2 жыл бұрын
Well, I guess you know now that we all need a t-shirt with "Hola, mis amigos de front-end!" on it, right?
@normanejm
@normanejm 2 жыл бұрын
Right now I have to fix a problem like this in my work. thanks!!! jajaa
@sergejstojanovic2518
@sergejstojanovic2518 2 жыл бұрын
Thank You.
@developer_hadi
@developer_hadi 2 жыл бұрын
your camera is awesome
@KevinPowell
@KevinPowell 2 жыл бұрын
Thanks!
@DMPDEV
@DMPDEV 2 жыл бұрын
awesome! I do have a question though, is there a way with only CSS and no Js?
@outpost31737
@outpost31737 2 жыл бұрын
I use vanilla JS to solve this problem simply by executing a piece of code that calculates the height of the header (ScrollTop).
@ubaidnoor6598
@ubaidnoor6598 Жыл бұрын
Amazing 🤩
@justkailash
@justkailash Жыл бұрын
Thankyou... save my life ...
@codeaz5673
@codeaz5673 19 күн бұрын
thanks sir
@QwDragon
@QwDragon 2 жыл бұрын
Actually the was a way of making similar thing with paddings and margins, but a spicial property is much simplier!
@mhcostapimenta
@mhcostapimenta 2 жыл бұрын
Awesome!!!!
@johannes.kielmann
@johannes.kielmann 2 жыл бұрын
navigationHeight - 1 + "px" is that really doing math with the first two elements and then adding "px" to the result to get a string? JavaScript really is magical :D
@cranjismcbasketball8113
@cranjismcbasketball8113 Жыл бұрын
Thanks for the video. Unfortunately, the link you provided to the code doesn't exist anymore
@katemc516
@katemc516 2 жыл бұрын
I have a similar problem, except the fixed nav pops up at the bottom (I have to use absolute in this case), it always blocks the last bit of the content when it does so I added conditional extra padding-bottom to the content when the nav pops up. Now the problem is the content is extended by that extra padding therefore pushing the nav further down so after it pops up I have to scroll down again to see it, so is there any CSS or JS code to make the content scroll down to the very bottom? Also love your videos 😊
@bewhee
@bewhee 2 жыл бұрын
Now convince every website to hide the damn things. Or just move them to the side, on landscape mode, where there is plenty of space!
@Steel0079
@Steel0079 2 жыл бұрын
I have never used observers, when you were talking about workarounds for resizing i thought you were going to mention event listeners. Is the observer a more convenient option? Or are there more advantages to observer approach?
@KevinPowell
@KevinPowell 2 жыл бұрын
tbh, you could probably just use window.resize. from what I understand (and my JS knoweldge is a bit limited, so take it with a grain of salt), but resize observer tends to be more performant than using an eventListener for resize, but that's more for elements, which can have trickle down effects (and potentially even lead to infinite loops). On the window, I'm not sure if there is a benefit.
Flexbox or grid - How to decide?
18:51
Kevin Powell
Рет қаралды 760 М.
Are you using the right CSS units?
6:30
Kevin Powell
Рет қаралды 472 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Create a super fun "focus by negation" effect
32:06
Kevin Powell
Рет қаралды 20 М.
Subtle, yet Beautiful Scroll Animations
5:04
Beyond Fireship
Рет қаралды 1,8 МЛН
My best CSS tips from 2024
16:55
Kevin Powell
Рет қаралды 26 М.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 994 М.
Learn flexbox the easy way
34:04
Kevin Powell
Рет қаралды 742 М.
Animate from display none
21:55
Kevin Powell
Рет қаралды 162 М.
This Simple Trick Makes Your Website 83% Better Looking
10:57
Web Dev Simplified
Рет қаралды 404 М.