Sticky Footer is Not Giving Sticky Behavior [closed] - html

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
christianselig.com/contact
For some reason the footer only sticks half way up the page on this one page, but all the others are seemingly okay. I've looked for ages and can't peg the reason.
I've put the relevant HTML and CSS below, and anything more is obviously available.
HTML:
<div class="alt-contact">
<p>Prefer manual contacting? Email me.</p>
</div>
</div> <!-- This div corresponds to the content wrapper div above -->
<div class="footer-wrapper">
<div class="footer">
<p class="copyright">Copyright © 2012 Christian Selig</p>
<ul>
<li>Home</li>
<li>About</li>
<li>Work</li>
<li>Contact</li>
</ul>
</div>
</div>
CSS:
.footer-wrapper {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #d6d6d6 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#d6d6d6)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#d6d6d6 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#d6d6d6 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#d6d6d6 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#d6d6d6 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#d6d6d6',GradientType=0 ); /* IE6-9 */
border-top: 1px solid #ccc;
bottom: 0;
height: 16px;
overflow: hidden;
padding: 8px 0 5px 0;
position: absolute;
width: 100%;
}
.footer {
color: #808080;
clear: both;
font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
font-size: 0.7em;
margin: auto;
width: 900px;
}

You should have:
html,
body {
height: 100%;
}
Your html has no height given to it, so it's only as tall as the body pushes it. Note, in IE8 and less you have to use "tricker" solutions like Ryan Fait's Sticky Footer:
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
/* the bottom margin is the negative value of the footer's height */
margin: 0 auto -142px;
}
.footer, .push {
/* .push must be the same height as .footer */
height: 142px;
}
/* Sticky Footer by Ryan Fait
http://ryanfait.com/ */
I've used it; it works. It gives you headaches, though, because it essentially takes margin and padding flexibility away from you. Which can be a pain.

Yes, it's because position: absolute; doesn't make sticky footers. If you want a sticky footer, you need to use position: fixed;. this will make the footer stay in the same spot relative to the browser window, as opposed to the next relevant parent object.
Good Luck,
-Brian

Related

CSS: Two-color background

This might not be the best title, but I am having a hard time trying to find the appropriate one. Basically, what I need is to have a two-color background image, with the breakpoint set to a specific position.
Here's what I have right now:
Which can be tested in this jsfiddle.
And this is what I am trying to achieve:
One thing though, is that the slant in this bar needs to be aligned with the logo, as shown below:
If there was no slant, this might be easier, but I have not found a way to achieve the desired behavior. What I tried doing was creating a div with a background color, and inside that div, a second one that would be placed on top containing the image.
<div class="line-container">
<div class="line">
</div>
</div>
.line-container{
width: 100%;
background-repeat: repeat-x;
background-color: #009b3a;
}
.line{
background-image: url('http://s8.postimg.org/fc0umdjut/image.png');
display: block;
width: 50m;
margin: 0 auto;
height: 10px;
}
But position and color to the sides are wrong, as shown in this jsfiddle:
Any advise?
Seems like a job for a gradient.
background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(45deg, #1e5799 0%, #1e5799 48%, #2989d8 48%, #7db9e8 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(45deg, #1e5799 0%,#1e5799 48%,#2989d8 48%,#7db9e8 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(45deg, #1e5799 0%,#1e5799 48%,#2989d8 48%,#7db9e8 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
Simply add this to your css class and change the colors within accordingly.
Even though the accepted answer is great, I wanted to share an alternative to using gradients.
Here's an option using the ::before pseudo-class with a CSS border trick to get the angled portion. You can adjust the "angle" by tweaking the border widths. The width property on the pseudo-element can be adjusted, as needed.
div {
background: green;
height: 10px;
position: relative;
}
div:before {
background: darkgreen;
border: solid transparent 0;
border-bottom-width: 10px;
border-right-color: green;
border-right-width: 10px;
box-sizing: border-box;
content: '';
height: 10px;
position: absolute;
width: 5em;
}
<div></div>

Getting gradient background color to due full cycle on the outside of a wrapper

I have a page on my site that has a gray background color that I am trying to add gradient to it in a different way than just a left to right. My page has an outer div that takes up 100% of the page's width. I then have an inner div that takes up 80% of the page's with, but auto aligned. I was wondering how, if I can, do a full cycle of my gradient within each side (left & right) of the outer div, the 10% part that shows before the inner div starts.
So say an A equals 10%, and everytime I put two colors together, that is the gradient taking place within that 10%. I want to do this...
#181818, #282828 AAAAAAAA #282828, #181818
How can I do this?
HTML
<div class="graypage">
<div class="homeimg">
gfdsgsg
</div>
</div>
CSS
.graypage, .whitepage { margin: 0 auto; }
/*------Page Wraps--------*/
.graypage {
width: 100%;
left: 0;
right: 0;
min-height: 100%;
background: -webkit-linear-gradient(left, #282828, #181818); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right, #282828, #181818); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, #282828, #181818); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, #282828, #181818); /* Standard syntax */
}
.homeimg {
background-image: url("/images/bright_lights_small.jpg");
width: 80%;
background-size: cover;
background-position: center;
height: 100%;
position: absolute;
margin-right: 10%;
margin-left: 10%;
}
As I understand it, you'd like two bars - one on the left of the outerDiv and the other on the right. Each of these bars you'd like to be 10% of the page width. You'd also like each bar to cycle through the colours #181818, #282828, #aaaaaa, #282828, #181818.
I'd just use a linear-gradient with 12 colour-stops. Something like this:
#outerDiv
{
background: linear-gradient(to right,
#181818 0%,#282828 2%,#aaaaaa 4%,#aaaaaa 6%,#282828 8%,#181818 10%,
#181818 90%,#282828 92%,#aaaaaa 94%,#aaaaaa 96%,#282828 98%,#181818 100%); /* W3C */
width: 100%;
}
Credit: http://www.colorzilla.com/gradient-editor/
Here it's applied to the outer div and a solid colour is applied to the (80% as wide) inner div.
EDIT: Here's the (now updated) html and css used.
<style>
body
{
margin: 0;
padding: 0;
}
#outerDiv
{
background: linear-gradient(to right,
#181818 0%,#282828 10%,
#282828 90%,#181818 100%); /* W3C */
width: 100%;
}
#innerDiv
{
width: 80%;
margin: auto;
background-color: #dddddd;
}
</style>
</head>
<body>
<div id='outerDiv'>
<div id='innerDiv'>
<button id='goBtn'>Change the text</button>
<div class="menu-wrapper">
<ul>
<li>WORD1</li>
<li>WORD2</li>
<li>WORD3</li>
<li>WORD4</li>
</ul>
</div>
</div>
</div>
</body>
This code produces the following result:
Bacically, you have 2 posibilities here. You can set a repeating gradient
div {
width: 500px;
height: 100px;
background: repeating-linear-gradient(to right, yellow 0%, green 10%);
}
<div></div>
And you can play with the background-size
div {
width: 500px;
height: 100px;
background: linear-gradient(to right, yellow, green);
background-size: 10% 100%;
}
<div></div>

CSS positioning isn't moving the image?

So I'm in the process of making a drag and drop browser 'dress up' type game. However, for some reason, I can't seem to position my images - either the draggable image or the doll base. I am able to drag and drop the draggable image, but I can't change their initial positions.
I've changed their position types, tried using top/bottom/left/right, margin, and even padding to move the images to where I want them, but they absolutely will not move!
Here's the HTML/CSS I'm using:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style>
<!--Page Styling-->
html, body{
background-color:#5C5C5C;
height: 100%;
width: 100%;
overflow: hidden;
}
#banner{
background: rgb(143,250,138); /* Old browsers */
background: -moz-linear-gradient(top, rgba(143,250,138,1) 0%, rgba(127,239,127,1) 10%, rgba(109,223,115,1) 25%, rgba(107,229,115,1) 37%, rgba(106,236,114,1) 50%, rgba(74,226,82,1) 51%, rgba(136,242,122,1) 83%, rgba(175,252,142,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(143,250,138,1)), color-stop(10%,rgba(127,239,127,1)), color-stop(25%,rgba(109,223,115,1)), color-stop(37%,rgba(107,229,115,1)), color-stop(50%,rgba(106,236,114,1)), color-stop(51%,rgba(74,226,82,1)), color-stop(83%,rgba(136,242,122,1)), color-stop(100%,rgba(175,252,142,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(143,250,138,1) 0%,rgba(127,239,127,1) 10%,rgba(109,223,115,1) 25%,rgba(107,229,115,1) 37%,rgba(106,236,114,1) 50%,rgba(74,226,82,1) 51%,rgba(136,242,122,1) 83%,rgba(175,252,142,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(143,250,138,1) 0%,rgba(127,239,127,1) 10%,rgba(109,223,115,1) 25%,rgba(107,229,115,1) 37%,rgba(106,236,114,1) 50%,rgba(74,226,82,1) 51%,rgba(136,242,122,1) 83%,rgba(175,252,142,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(143,250,138,1) 0%,rgba(127,239,127,1) 10%,rgba(109,223,115,1) 25%,rgba(107,229,115,1) 37%,rgba(106,236,114,1) 50%,rgba(74,226,82,1) 51%,rgba(136,242,122,1) 83%,rgba(175,252,142,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(143,250,138,1) 0%,rgba(127,239,127,1) 10%,rgba(109,223,115,1) 25%,rgba(107,229,115,1) 37%,rgba(106,236,114,1) 50%,rgba(74,226,82,1) 51%,rgba(136,242,122,1) 83%,rgba(175,252,142,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8ffa8a', endColorstr='#affc8e',GradientType=0 ); /* IE6-9 */
font-size: 20px;
font-family: 'Arial Black', sans-serif;
width: 100%;
margin-left: -10px;
text-align: center;
z-index: 99999;
position: fixed;
}
#holder{
position: absolute;
height: 800px;
width: 900px;
background-color: #838B8B;
margin-left: -10px;
margin-top: -300px;
z-index: -1;
}
<!--Bodies-->
#body1 {
position: absolute;
right: 0;
height: auto;
width: 200px;
z-index: 1;
}
<!--Parts-->
#breath{
position: relative;
left: 10px;
}
</style>
<!--Draggable Scripts-->
<script>
$(function() {
$( "#breath" ).draggable();
});
</script>
<!--End Draggable Scripts-->
</head>
<body>
<div id="banner">Homestuck Character Editor</div>
<div id="body1"><img src="http://i.imgur.com/aO3GWBO.png"draggable="false"/></div>
<div id="holder"></div>
<div id="breath">
<img src="http://i.imgur.com/iAmOFlH.png"/>
</div>
</body>
</html>
You positioned the div on the right, but the image is still on the left. Since div elements are blocks, they fill 100% of their parent. In this case, the parent is 100%. You can get the image on the right side of the screen by selecting it, and shifting the image itself. I used the following:
#body1 img {
position:absolute;
right:0;
}
The fiddle.

Divs not nesting correctly inside section tag

I'm using the following HTML and CSS code to try and create a section with 3 divs inside of it, the problem is that even though the divs are inside the section tag, in the web page they appear outside and below the section element?
HTML code
<section id="content">
<div class="homebox">
<h3>Who I am</h3>
<p>Here is some text Here is some text Here is some text Here is some text </p>
</div>
<div class="homebox">
<h3>What I do</h3>
<p> Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text </p>
</div>
<div class="homebox">
<h3>Where I do it</h3>
<p> Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text </p>
</div>
</section>
Here is the CSS code I'm using
#content {
color:#FFF;
margin-top: 20px;
width: 100%;
padding-left: 20px;
}
#content h3 {
color:#FFF;
font-size: 40px;
font-family: Impact, Arial, sans-serif;
margin:0;
font-weight: 100;
}
#content > .homebox {
float:left;
width: 28%;
padding: 0px 20px 20px; /* Top 0 padding, left and right 20px, bottom 20px padding */
margin-right: 18px;
text-align:center;
border-radius:40px;
background: #818181;
background: -moz-radial-gradient(center, ellipse cover, rgba(234,211,0,0.6) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(234,211,0,0.6)), color-stop(63%,rgba(255,255,255,0.22)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, rgba(234,211,0,0.6) 0%,rgba(255,255,255,0.22) 63%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, rgba(234,211,0,0.6) 0%,rgba(255,255,255,0.22) 63%,rgba(255,255,255,0) 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, rgba(234,211,0,0.6) 0%,rgba(255,255,255,0.22) 63%,rgba(255,255,255,0) 100%); /* IE10+ */
background: radial-gradient(ellipse at center, rgba(234,211,0,0.6) 0%,rgba(255,255,255,0.22) 63%,rgba(255,255,255,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#99ead300', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.homebox > p {
margin: 0px;
color: #FFF;
font-family: Trebuchet MS, Arial, sans-serif;
}
You need to either clear your floats or trigger a new block formatting context:
#content {
color:#FFF;
margin-top: 20px;
width: 100%;
padding-left: 20px;
overflow: auto; /* Will cause all child floats to be enclosed. */
}
How This Works - Block Formatting Contexts
By adding the overflow: auto property to a block element, the CSS engine triggers a new block formatting context. This means that all the content with the block will be formatted within the block and disregard any elements outside of the block. If you have floats, then the floats pay attention to the edges of the parent element and are not affected by any content outside of the parent.
Reference: http://www.w3.org/TR/CSS2/visuren.html#block-formatting

Can I have a 1000px-wide <div> contain a 1300px-wide <div>?

For that matter, can I place any wide div in a narrower div? What I'm trying to do can be explained by looking at this page.
What I'm trying to do is have the div with the 1300px-wide SVG graphic – whose id is "wide2" – overlap over the div called "center." The problem is that, when I just put wide2 into center, it aligns left. Both the classes of div have margin-left: auto and margin-right: auto CSS properties, which work, assuming the div contained in "center" is narrower than "center."
My solution so far has been closing "center", then immediately opening "wide2", and then, immediately after closing that one, re-opening "center." It's not a great system, especially given the shape of the SVG in question.
Can anyone help me out?
(per request) The CSS of the classes in question.
div.center
{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 0;
margin-bottom: 0;
padding-bottom: 0;
padding-top: 0;
height: 100%;
width: 1000px;
background: #bebebe; /* Old browsers /
background: -moz-linear-gradient(left, #bebebe 0%, #ffffff 12%, #ffffff 88%, #bebebe 100%); / FF3.6+ /
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#bebebe), color-stop(12%,#ffffff), color-stop(88%,#ffffff), color-stop(100%,#bebebe)); / Chrome,Safari4+ /
background: -webkit-linear-gradient(left, #bebebe 0%,#ffffff 12%,#ffffff 88%,#bebebe 100%); / Chrome10+,Safari5.1+ /
background: -o-linear-gradient(left, #bebebe 0%,#ffffff 12%,#ffffff 88%,#bebebe 100%); / Opera 11.10+ /
background: -ms-linear-gradient(left, #bebebe 0%,#ffffff 12%,#ffffff 88%,#bebebe 100%); / IE10+ /
background: linear-gradient(left, #bebebe 0%,#ffffff 12%,#ffffff 88%,#bebebe 100%); / W3C /
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bebebe', endColorstr='#bebebe',GradientType=1 ); / IE6-9 */
border-bottom: 0;
border-top: 0;
margin-top: 0;
margin-bottom: 0;
padding-bottom: 0;
padding-top: 0;
}
div.wide2
{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 0;
margin-bottom: 0;
padding-bottom: 0;
padding-top: 0;
height: 180;
width: 1300px;
border-bottom: 0;
border-top: 0;
margin-top: 0;
margin-bottom: 0;
padding-bottom: 0;
padding-top: 0;
}
Here is a CSS solution.
Add the following lines into your .wide2 css class:
margin-left: 50%;
transform: translate(-50%);
What's happening is you first move the wider div to the center of the narrower div, then translate the inner div left.
You can see it in action here: https://jsfiddle.net/89f31era/
The question is very unclear. I presume you want to
a div which is narrow, lets call it div1, width - 500px
a div which is wider, lets call it div2, width - 1000px
place div2 inside div1
Scroll div1 horizontally so as to see center div2 on div1.
You may use the ScrollLeft DOM property to perform scrolling. Ex:
<div style="background-color:#093; width:200px; overflow:scroll" id="sc1">
<div style="background-color:#033; width:400px;">
</div>
</div>
<script type="text/javascript">
document.getElementById("sc1").scrollLeft="30";
</script>