This question already has answers here:
CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page
(37 answers)
How do you get the footer to stay at the bottom of a Web page?
(32 answers)
Closed 3 years ago.
So, I am trying to achieve this:
I know this looks like an already asked question but I have tried all the available solutions of stackoverflow.
My current structure is:
HTML:
<div class='app'>
<div class='content'>Content</div>
<div class='footer'>Footer</div>
</div>
CSS:
.app{
text-align: center;
background-color: #1a1f25;
min-height: 100%;
width: 100%;
position: relative;
overflow-y: auto;
top: 0;
}
.footer{
color: lightgray;
padding: 10px 30px;
position: absolute;
width: 100%;
font-size: 10px;
background: black;
bottom: 0;
}
Update: I tried checking the answer given here, but my website is responsive and that answer is for those footers which have fixed height. Which makes it difficult to convert that solution for my usecase.
Related
This question already has answers here:
How to center an element horizontally and vertically
(27 answers)
Closed 3 years ago.
I am trying to center the disc in the middle of the page overlapping my left and right div. The way I have found to do it is using the below code however, the disc shoots off the page to the right when I do. Please can someone help me understand why as I have googled and watched YouTube videos and they say this is how you do it. It is even working in the YouTube video but not for me. I am really stuck.
body {
margin: 0;
}
.container {
height: 100vh;
display: flex;
}
.left {
width: 50vw;
display: relative;
background-color: #abc;
}
.right {
width: 50vw;
background-color: #687;
}
.disc {
width: 16em;
height: 16em;
border-radius: 50%;
background-color: black;
position: absolute;
top: 50%;
right: -8em;
transform: translateY(-50%);
}
<div class="container">
<div class="left">
<div class="disc"></div>
</div>
<div class="right"></div>
</div>
If I understood correctly you want to position the disc in the middle horizontaly.
If that's the case, you can use the right property in conjunction with the CSS calc function to get the desired behavior, like this:
...
.disc {
...
right: calc(50vw - 8em);
...
}
...
Where vw stands for viewport width and 8em is half of the disc width.
You can see the complete code here.
To position a child element, the parent element need to have a position attribute (position: relative; atleast) for its childs to inherit. That is why your .disc element went off to the right.
So simply add
position: relative;
to the parent elements, the .left and .right class
I hope this helps
This question already has answers here:
How do you get the footer to stay at the bottom of a Web page?
(32 answers)
Closed 5 years ago.
So I am making a website like a little mock up one as I have just started learning and the footer just won't stay at the bottom and it is killing me. When I load the page it starts at the bottom and then when I scroll down it stays in the same place and is stuck where it started and won't start at the bottom of the page.
#footer {
text-align: right;
padding: 10px;
background-color: #07889B;
position: absolute;
bottom: 0;
width: 1200px;
}
This should work
#footer {
text-align: right;
padding: 10px;
background-color: #07889B;
position: fixed;
bottom: 0;
left:0;
width: 1200px;//or width:100%;
}
This question already has answers here:
CSS Single-column layout centered fixed-width 100% height w header and footer
(5 answers)
Closed 6 years ago.
I know, this kind of questions has been asked a lot, but somehow the correct answer is always eluding me...
Ok, I've got two things I want:
A footer that's always on the bottom of the page, no matter if the content has less height than the available screen or more.
The content above the footer should fill the rest of the screen - or use more space, if needed
The first part is quite easy, for example, here, with something like this...
.footer {
position: absolute;
bottom: 0;
left: 0;
}
No problem there. But how can I get the content above the .footer element to fill the remaining space? height=100%; obviously doesn't work;
Anyone got an idea how to realize a layout with...
A fixed header
A footer at the bottom of the screen (or below, if the content needs more height than that)
A content that fills the available screen or uses more, if needed
(The reason is that in the end, I want a grid with flexible height that fills the screen in the content)
header {
width: 100%;
position: fixed;
background-color: #9f0d0d;
color: #f5f5f5;
border-bottom: 1px solid #ddd;
min-height: 5%;
}
header :first-child {
vertical-align: middle;
margin-top: auto;
margin-bottom: auto;
}
article {
top: 55px;
width: 100%;
height: 90%;
position: fixed;
}
footer {
top: 95%;
min-height: 5%;
width: 100%;
position: fixed;
padding: 10px 15px;
background-color: #9f0d0d;
color: #f5f5f5;
border-top: 1px solid #ddd;
}
<div>
<header>HEADER</header>
<article>CONTENT</article>
<footer>FOOTER</footer>
</div>
Feel Free to play with this code block.
This question already has answers here:
How do I get a div to float to the bottom of its container?
(37 answers)
Closed 8 years ago.
I'm having an issue with my html / css. I want to have a "learn more" box in every one of my three sections, located at the bottom middle of each one.
http://jsfiddle.net/9uxGq/4/
CSS
#learn {
position: absolute;
margin-left: auto;
margin-right: auto;
bottom: 0;
background-color: rgba(255, 255, 255, 0.6);
z-index:1;
margin-bottom: 20px;
left:50%;
width: 150px;
margin-left: -75px;
text-align: center;
line-height: 50px;
}
#learn a {
color: black;
font-weight: bold;
}
It seems to work fine in the top box:
<div id="learn">Learn More
However in the section below I use pretty much the same code:
<section id='a1' style="height:100%;background-color:white;">
<div class="container"></div>
<div id="learn">Learn More
</section>
However this time the learn more box doesn't appear. What is it I am doing wrong? I have played around with position: relative without much luck.
TLDR: The learn more box should be at the bottom middle of the header and sections, it only appears in the header.
P.s I tried to strip down my code and css but didn't want to strip out any more as I believe its inclusion will highlight which options will / wont work.
Add this to your CSS:
section {
position: relative;
}
Demo: http://jsfiddle.net/9uxGq/5/
This question already has answers here:
CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page
(37 answers)
Closed 8 years ago.
Can anyone help me why the footer is not going to bottom of page?
http://dev.unwaveringmedia.com/billy/
You can see the space after black footer. I don't need that and want the footer be exactly positioned on the bottom of page?
You have many options to deal with this issue.
Option 1
.footer-container{
position:absolute;
bottom:0;
}
Option 2
Use a sticky footer
Option 3
html, body {
padding: 0;
margin: 0;
height: 100%;
}
#wrapper {
min-height: 100%;
position:relative;
}
#content {
padding-bottom: 75px; /* This value is the height of your footer */
}
.footer-container {
position: absolute;
width: 100%;
bottom: 0;
height: 75px; /* This value is the height of your footer */
}
You just need some content before the footer (or try one of the other options listed above).
I did this and it fixed it:
Right before the <div class="footer-container">
Enter this html: <div style="min-height:500px;">test</div>
That makes it work normally. So that should show you the problem you have. Either give it a minimum height, or just add your content in there (some lorem ipsem, etc.) or find another way to fix it.
try this
.footer-container {
bottom: 0;
margin: 0 auto;
position: absolute;
width: 100%;
}
You should give .footer-container to bottom:0; and position:absolute to fix footer at bottom.
.footer-container {
bottom: 0;
position: absolute;
}