CSS - Push footer to bottom of page, not screen [duplicate] - html

This question already has answers here:
How do you get the footer to stay at the bottom of a Web page?
(32 answers)
Closed 7 years ago.
I have this setup on my page, this works fine if the head + content + foot fits the screen height. But when the content grows, it will grow under the foot, instead of pushing the foot to the bottom of the page.
How can I fix this?
<body>
<div class="head">
Head
</div>
<div class="container">
Content
</div>
<div class="foot">
Foot
</div>
</body>

You probably have CSS doing that. If you have this HTML without markup, that doesn't happen.
Most likely, you have a CSS that looks like this, which needs to be removed.
.foot {
position: fixed;
bottom: 0;
}

Related

Footer and page size [duplicate]

This question already has answers here:
CSS Single-column layout centered fixed-width 100% height w header and footer
(5 answers)
Closed 7 months ago.
Feels like should already know how to achieve this effect, but I don't, so here goes:
I want footer to be placed at the bottom of the page if there is not enough content and if the page is filled I want it to be after all the content. So when you scroll it's not sticky.
Could you please help with this?
This can be achieved easily using Flexbox and setting min-height: 100vh to the main container.
I would suggest having a look at the Flexbox documentation (from MDN).
<body>
<div style="min-height: 100vh; display: flex; flex-direction: column;">
<header>
Header
</header>
<main style="flex: 1 0 auto; background: red;">
Some content.
</main>
<footer>
Footer
</footer>
</div>
</body>

css margin pushing body [duplicate]

This question already has answers here:
CSS margin terror; Margin adds space outside parent element [duplicate]
(7 answers)
Closed 4 years ago.
I'm Coding a sign in/sign up website, the css is very basic at this time along with basic js (I plan on polishing css). But I want to get the basic css done before working on html, one element of my website is an h3 element that I want to have a margin that pushes from the bottom of one of the selection divs but the margin is pushing from the top of the body rather than the containing div.
<div id="container">
<div id="leftFloat" class="50%">sign in</div>
<div id="rightFloat" class="50%">sign up</div>
<div id="rightFloat" class="50%">
<h2 id="selection" class="margin: 50px;">Pushes the container down rather than pushing itself down</h2>
</div>
</div>
This is what i want When Using The Margin
This is what i get when using the margin
Use clear:both for h2 as shown below:
h2{
clear: both;
}

How to set margin-top proeprly in WordPress? [duplicate]

This question already has answers here:
How do nested vertical margin collapses work?
(3 answers)
Closed 5 years ago.
I am making the footer of my WP custom theme. I have footer div(inside which I place components). I also have a logo div(where my logo is). I need distance from 12px between the begening of the footer div till the logo div.
I am using this:
<div class="footer">
<div class="footerlogo">
<img id="pic" src="<?php bloginfo('template_url') ?>/img/footer_logo.png">
</div> .......
.footerlogo{ margin-top:30px;}
It doesnt show any differance. WHat is the proper way of doing that?
enter image description here
You could use padding on the footer div, for example:
.footer {
padding-top: 12px;
}
This would add space between both the .footer and .footerlogo div elements.
https://jsfiddle.net/ss7Lp2nd/

How to make a limited size page-spanning background in html/css [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am a self taught coder developing a website for a nonprofit I've founded, and would like to have a footer to thank the sponsors of said nonprofit. I'm trying to distinguish this section from the rest of the site by changing its background color relative to the rest of my webpage. I've tried everything I can think of, like creating a div/footer with a width of 100% and a different background-color, but that only adds background colors to the portions of the div that contain text (the text appears to be highlighted with this color, rather than the color being a solid background applied to the entire div). All of my research has only turned up results for either how to make the entire background of a page a specific color, or how to add styles to horizontal rules, neither of which help me (the former because I want the color to differ from that of the rest of the page, and the latter because I am unable to put the content/text I would like to include over it). If anyone could help, it would be much appreciated. Thank you!
Edit: Clarification has been requested. Essentially, I was creating a footer for my website that I wanted to look like the one here with that black bar at the bottom that spans the page. My issue was that the div I was creating didn't span the page well enough to make it a solid bar; it was more of a blocky coloring that only showed up in nested divs containing text. I posted this question because I wasn't able to find any guides on how to span the page with a footer like this, but adding a nested div with the color background I wanted and a width of 100vm, setting the margins to 0, and hiding overflow ultimately let me accomplish my intent. Hopefully this is adequate clarification. I'd also appreciate if the downvote I accrued were removed, or at least explained; it's difficult to improve my posts if I don't know the issue with them
It's kind of hard to tell what the exact issue is without a visual example of your issue. But from the sounds of it, you want the background to extend the entire width of the page, but don't want the actual content to extend the entire width.
To do this, I would introduce a class that represents the width you want your content to be, and put that class nested within the footer (and any other elements on the page) where you want the parent (ie, the footer) to extend the width of the page, and everything inside the footer to be contained within the width that you want the content to be displayed. Here is an example, where the class I"m referring to is .viewport. Assigning a background to your footer and nesting .viewport within the footer will give the footer a full-width background, while leaving the text nested within the footer at your specified width.
body {
margin: 0;
}
header {
background: #eee;
}
.viewport {
max-width: 960px;
width: 90%;
margin: auto;
}
footer {
background: #171717;
color: #fff;
}
.section {
padding: 2em 0;
}
<header class="section">
<h1 class="viewport">
This is a header
</h1>
</header>
<main class="section">
<div class="viewport">
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
<p>hello world</p>
</div>
</main>
<footer class="section">
<p class="viewport">This is a footer</p>
</footer>
Here is a quick fix for you:
HTML
<div class="Footer">
<div class="Content">Place you stuff here</div>
</div>
CSS
.Footer{position:relative; width:100%; height:100px; display:block; float:left; background-color:RED;}
.Footer > .Content{position:relative; margin:auto; width:80%; height:100%;}
The best and easiest solution is with bootstrap but since you didnt mention it that means you are not using it.
<footer>
<div class="sponsors">
Type anything you want
</div>
</footer>
CSS:
.sponsors{
text-align:center;
background-color:(your color);
}
This should work, if not tell me what went wrong!

sticky footer on the bottom of the page [duplicate]

This question already has answers here:
Problem with CSS Sticky Footer implementation
(5 answers)
Closed 8 years ago.
I know that there are tons of answer out there. I spent many many hours trying to figure out what it not working.
I want to have a sticky footer.
the html structure is like this
<body>
<div id=container>
<div id=header>
</div>
<div id=body>
<div id=left>
</div>
<div id=center>
</div>
<div id=right>
</div>
</div>
<div id=footer>
</div>
</div>
</body>
and a link with the css and the content link
Change your footer position from "absolute" to "fixed"
If you want to have the footer always be at the bottom of the screen/window you can add the following to your css
#footer {
position: fixed;
bottom: 0;
}