Thank you, I trying to put all my knowledge in the footer and body, but was more simple that I was thinking. I hope you have a nice day wherever and whenever you read this.
There is an easier way to achieve this. First, set the parent element (which could be the 'body') to have the following CSS properties: 'flex-direction: column;', 'min-height: 100vh;', and 'display: flex;'. Secondly, in your 'footer' class, simply add 'margin-top: auto;'. That's all you need to do.
It can be as shown below: html { height: 100%; box-sizing: border-box; } body { margin: 0; display: flex; /* This makes the body a flex container */ flex-direction: column; /* Sets the flex container to have a vertical column layout. */ min-height: 100vh; /* Ensures that the body takes up at least the full height of the viewport. */ box-sizing: inherit; } footer { background: greenyellow; font-size: 18px; padding: 35px; text-align: center; margin-top: auto; /* Push the footer to the bottom */ } Note: padding-bottom: 6.74rem; - no longer necessary due to the use of flexbox to position the footer at the bottom. This property was originally used for pushing the footer down when using absolute positioning.
I have a question.. My page has header and a footer and a" sign up " form. Whenever i want to write in the sign up form the footer comes up my keyboard( im on mobile). I did what you did and the problem isnt solved. But my footer is successfully sticky in the bottom.. But when i write in the form.. It gets up and blocks the input bars.. Do you have any recommendation what to do to fix it??
Thanks for reaching out. I understand the issue you're facing with the footer blocking the input bars when using the sign-up form on mobile. You can try the following adjustments: Adjust Footer Positioning: Modify the CSS for your footer to make it sticky only when needed. Update the position property to "fixed" for normal situations and "absolute" or "relative" when the keyboard is active. footer { text-align: center; position: fixed; /* Change to "absolute" or "relative" when the keyboard is active */ right: 0; left: 0; bottom: 0; } Use JavaScript to Detect Keyboard: If the CSS adjustment alone doesn't solve the problem, you can use the following JavaScript to dynamically detect keyboard activity and adjust the footer position accordingly. window.addEventListener('resize', function() { var footer = document.querySelector('footer'); if (window.innerHeight < window.screen.height) { // Keyboard is active, make the footer relative or absolute footer.style.position = 'absolute'; // or 'relative' } else { // Keyboard is not active, make the footer sticky footer.style.position = 'fixed'; } });
I have one issue with my page, i have header main and footer , when i enter text in main , the text show all the way up under the footer ! i made the header transparent and i can see the text but i want the text right under the header automatically, any help will be appreciate .
Easiest and the most in depth explanation. You helped me fix a problem that has been bugging me for a while. Thank you!
Great to hear! 🙏
Thank you, I trying to put all my knowledge in the footer and body, but was more simple that I was thinking. I hope you have a nice day wherever and whenever you read this.
Same to you! Thanks a lot!
Wow this is the best on the whole internet, thanks! I really needed this for a school project, but I'll use it on my own webpage too.
Thanks for your kind words. 🙏🙏🙏😋
THANKS BRO HELPED A LOT been struggling for days and this one made my code work right.
Glad to hear it.
Great tutorial, helped me with 2 day's of struggling, Thank's a lot!
😍😋🙏
Thank you! It worked well. Sometimes, CSS doesn't have a clearly solution for such a simple issue.
Great to hear! 👍
There is an easier way to achieve this. First, set the parent element (which could be the 'body') to have the following CSS properties: 'flex-direction: column;', 'min-height: 100vh;', and 'display: flex;'.
Secondly, in your 'footer' class, simply add 'margin-top: auto;'.
That's all you need to do.
It can be as shown below:
html {
height: 100%;
box-sizing: border-box;
}
body {
margin: 0;
display: flex; /* This makes the body a flex container */
flex-direction: column; /* Sets the flex container to have a vertical column layout. */
min-height: 100vh; /* Ensures that the body takes up at least the full height of the viewport. */
box-sizing: inherit;
}
footer {
background: greenyellow;
font-size: 18px;
padding: 35px;
text-align: center;
margin-top: auto; /* Push the footer to the bottom */
}
Note: padding-bottom: 6.74rem; - no longer necessary due to the use of flexbox to position the footer at the bottom. This property was originally used for pushing the footer down when using absolute positioning.
@@SirChogyal Thanks for this! It has really helped me with my assignment.
YOU ARE THE GOAT I LOVE YOU
thank you so much
Thank you very much, I have been trying to solve that for a long time and this tutorial has served me perfectly
Great to hear!😋
Thank you so much for this tutorial. You have helped me to do my assignments 😊
You're welcome 😊
Thanks a lot for solving my problem ❤
Most welcome 😊
Thanks bro. 🙂😄
Welcome 😊
Wow bro. Superb video😍
Thanks 🤗
many thanks ... exactly what I was looking for
👍👍👍
this solved my problem, thank you so much sir!
You are most welcome. It is great to hear from you.
you have saved my life : )
🙏😊😊
thanks man you help my problem as a beginner
Glad to hear it! There will be more beginner's guide coming up.
you're truly lifesaver!
Thanks!
Thank you for the simple explanation. It worked for me!
I am gad that it had worked for you. Thank you!
thank you , you are a good man
So nice of you 👍🙏😊👌
Hi, this solved my problem, thank you very much! Liked and subscribed!
Glad it helped 😋👍
Thank you so much, this helped me a lot!!!
Glad it helped!🥰
thank you man i help in my project
Great!
thank u sir i was workin on a project and was not able to put a right footer thank u for this video
Always my pleasure.💌
thanks for this Video! it was really helpful :D
Glad to hear from you. 🙏👍
Thank you! Great job do more!
Sure.
I have a question..
My page has header and a footer and a" sign up " form. Whenever i want to write in the sign up form the footer comes up my keyboard( im on mobile). I did what you did and the problem isnt solved. But my footer is successfully sticky in the bottom.. But when i write in the form.. It gets up and blocks the input bars..
Do you have any recommendation what to do to fix it??
Thanks for reaching out. I understand the issue you're facing with the footer blocking the input bars when using the sign-up form on mobile. You can try the following adjustments:
Adjust Footer Positioning:
Modify the CSS for your footer to make it sticky only when needed. Update the position property to "fixed" for normal situations and "absolute" or "relative" when the keyboard is active.
footer {
text-align: center;
position: fixed; /* Change to "absolute" or "relative" when the keyboard is active */
right: 0;
left: 0;
bottom: 0;
}
Use JavaScript to Detect Keyboard:
If the CSS adjustment alone doesn't solve the problem, you can use the following JavaScript to dynamically detect keyboard activity and adjust the footer position accordingly.
window.addEventListener('resize', function() {
var footer = document.querySelector('footer');
if (window.innerHeight < window.screen.height) {
// Keyboard is active, make the footer relative or absolute
footer.style.position = 'absolute'; // or 'relative'
} else {
// Keyboard is not active, make the footer sticky
footer.style.position = 'fixed';
}
});
@@SirChogyal Thanks for replying! Ill try it out 👍
Much appreciated man
😍🙏🙏
Thank you very very much 🙏🏼
You are very welcome
Thank u!!☺
from HongKong
You're welcome 😊 It's good to see you here.
I have one issue with my page, i have header main and footer , when i enter text in main , the text show all the way up under the footer ! i made the header transparent and i can see the text but i want the text right under the header automatically, any help will be appreciate .
Oh I see. Can you show me your sample project?
Thanks it works
Nice to see your kind words! It means a lot to me that my content was able to help you. 👍👍👍
Thank you !
You're welcome!👍
Why the specific 6.74rem on the padding-bottom?
That's not specific. You can adjust as per your wish.
thanks. it works for me
You're welcome!
sir why you gave 100 percent height to html tag in css ??
Setting the height of the HTML to 100% allows the web page to occupy the full height of the viewport.
Thanks so much!!
My pleasure!
not working for me as i increase the content footer overlaps
You have to adjust the padding-bottom as per your requirement. Hope this will fix your issue.
Excellent
Glad you found it helpful! 😊
Thanks a lot
Always my pleasure! Thanks for your kind words!
how do i do something similar on wordpress?
You can apply the same technique.
tengkiyu ....
My pleasure...👌
thanks brother
No problem ❤️
thanks!
No problem!
Very good
Thanks dude!
Great!
Thanks!
Thankuuuuu
🙏🙏🙏
👍👍👍👍
Thanks!