A website use this spoiler code:
https://codepen.io/oloman/pen/odnqy
input[id^="spoiler"] {
display: none;
}
input[id^="spoiler"]+label {
display: block;
width: 200px;
margin: 0 auto;
padding: 5px 20px;
background: #e1a;
color: #fff;
text-align: center;
font-size: 24px;
border-radius: 8px;
cursor: pointer;
transition: all .6s;
}
input[id^="spoiler"]:checked+label {
color: #333;
background: #ccc;
}
input[id^="spoiler"]~.spoiler {
width: 90%;
height: 0;
overflow: hidden;
opacity: 0;
margin: 10px auto 0;
padding: 10px;
background: #eee;
border: 1px solid #000;
border-radius: 8px;
transition: all .6s;
}
input[id^="spoiler"]:checked+label+.spoiler {
height: auto;
opacity: 1;
padding: 10px;
}
<input type="checkbox" id="spoiler" />
<label for="spoiler">Spoiler1</label>
<div class="spoiler">
Lorem ipsum dolor sit amet, Etiam congue, neque a commodo
</div>
<input type="checkbox" id="spoiler" />
<label for="spoiler">Spoiler1</label>
<div class="spoiler">
Lorem ipsum dolor sit amet, Etiam congue, neque a commodo
</div>
This works, when only 1 spoiler is visible. If multiple spoilers are available, only the first one is working (opening), when someone click at the next buttons.
Is there a way to make this individual without javascript and only with css, maybe with hasChild? Its not possible to use different ID´s.
I made a jsFiddle:
https://jsfiddle.net/swj38nmr/
We can achieve this effect -without javascript- using the html element details and a css keyframe:
Simplest example:
details[open] summary ~ * {
animation: spoiler 1s ease-in-out;
padding: 2rem;
background: pink;
border-radius: 1rem
}
#keyframes spoiler {
0% {opacity: 0; background: red; border-radius: 3rem}
100% {opacity: 1; background: pink; border-radius: 1rem}
}
<details>
<summary>
Spoiler
</summary>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eu sodales tortor, posuere mattis nunc. Integer eget sapien ullamcorper diam mollis laoreet. Praesent dignissim id urna at malesuada. Etiam id nisl vitae ante vestibulum volutpat.
</p>
</details>
<details>
<summary>
Spoiler
</summary>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eu sodales tortor, posuere mattis nunc. Integer eget sapien ullamcorper diam mollis laoreet. Praesent dignissim id urna at malesuada. Etiam id nisl vitae ante vestibulum volutpat.
</p>
</details>
<details>
<summary>
Spoiler
</summary>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eu sodales tortor, posuere mattis nunc. Integer eget sapien ullamcorper diam mollis laoreet. Praesent dignissim id urna at malesuada. Etiam id nisl vitae ante vestibulum volutpat.
</p>
</details>
Behave well on mobile.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details
Related
I need to force two buttons to the bottom of a container, floating one left and one right.
The caveats however are:-
The length of the content in the container may differ.
The width of the containers can not be fixed.
This needs to work responsively so at any device-width, the two buttons needs to retain a bottom-left and bottom-right, in proportion to all other elements effect.
.left {float: left;}
.right {float: right;}
.service-blocks {margin: 20px 0;}
.service-blocks ul {margin: 0 auto;}
.service-blocks li {
list-style: none;
width: 29.4%;
display: inline-block;
border: 2px solid #222;
padding: 10px;
margin: 0 1%;
min-height: 350px;
vertical-align: top;
position: relative;
}
.service-blocks li:first-of-type {margin-left: 0;}
.service-blocks li:nth-of-type(3) {margin-right: 0;}
.service-blocks li .button-container {
display: block;
position: absolute;
bottom: 10px;
}
.service-blocks li a.button {
display: inline-block;
font-weight: 400;
line-height: 1.25;
text-align: center;
text-decoration: none;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .5rem 1rem;
font-size: 1rem;
border-radius: .25rem;
-webkit-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
.service-blocks li a.button.enquire {
color: #fff;
background-color: #5cb85c;
border-color: #5cb85c;
}
.service-blocks li a.button.learn {
color: #fff;
background-color: #384C6A;
border-color: #384C6A;
}
<div class="service-blocks">
<ul>
<li>
<h2>Service 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin, ligula quis convallis accumsan, ipsum ex lobortis risus, a malesuada orci turpis vel leo. Fusce sit amet arcu est. Ut mi nunc, vestibulum eu urna sed, blandit euismod est. Aliquam ut gravida orci. Sed varius iaculis diam, efficitur rutrum massa blandit sed. Nam in odio ornare, fringilla ex in, dapibus tortor. Aliquam aliquet ac dui sit amet fermentum.</p>
<span class="button-container">
Enquire
Learn More
</span>
</li>
<li>
<h2>Service 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin, ligula quis convallis accumsan, ipsum ex lobortis risus, a malesuada orci turpis vel leo. Fusce sit amet arcu est. Ut mi nunc, vestibulum eu urna sed, blandit euismod est. Aliquam ut gravida orci. Sed varius iaculis diam, efficitur rutrum massa blandit sed. Nam in odio ornare, fringilla ex in, dapibus tortor. Aliquam aliquet ac dui sit amet fermentum.</p>
<span class="button-container">
Enquire
Learn More
</span>
</li>
<li>
<h2>Service 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin, ligula quis convallis accumsan, ipsum ex lobortis risus, a malesuada orci turpis vel leo. Fusce sit amet arcu est. Ut mi nunc, vestibulum eu urna sed, blandit euismod est. Aliquam ut gravida orci. Sed varius iaculis diam, efficitur rutrum massa blandit sed. Nam in odio ornare, fringilla ex in, dapibus tortor. Aliquam aliquet ac dui sit amet fermentum.</p>
<span class="button-container">
Enquire
Learn More
</span>
</li>
</ul>
</div>
I have created a basic demo here too in jsfiddle.
I have fiddled around with various relative -> absolute positioning, if I apply a width to .button-container then I can make the buttons float left and right but this seems rather clunky responsively, whether different px widths at different media queries or trying to a one-size-fits-all with a % width.
I'd prefer to keep this CSS only if possible but will consider jQuery if absolutely necessary.
use flex method and resize the button size according to container.
css:
.service-blocks li .button-container {
display: flex;
position: absolute;
bottom: 10px;
left: 0;
justify-content: space-between;
}
After setting the button container to absolute width will be set to auto to make container for available make use of left and right position properties.And then set the button positions to left ,right ,bottom 0px respectively.
Please check the following fiddle
.left {float: left;}
.right {float: right;}
.service-blocks {margin: 20px 0;}
.service-blocks p {width:225px}
.service-blocks ul {margin: 0 auto;}
.service-blocks li {
list-style: none;
width: 43.05%;
display: inline-block;
border: 2px solid #222;
padding: 10px;
margin: 0 1%;
min-height: 350px;
vertical-align: top;
position: relative;
}
.service-blocks li:first-of-type {margin-left: 0;}
.service-blocks li:nth-of-type(3) {margin-right: 0;}
.service-blocks li .button-container {
display: block;
position: absolute;
bottom: 10px;
left:0px;
width:100%;
}
.service-blocks li a.button {
display: inline-block;
font-weight: 400;
line-height: 1.25;
text-align: center;
text-decoration: none;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .5rem 1rem;
font-size: 1rem;
border-radius: .25rem;
-webkit-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
.service-blocks li a.button.enquire {
color: #fff;
background-color: #5cb85c;
border-color: #5cb85c;
left:0px;
}
.service-blocks li a.button.learn {
color: #fff;
background-color: #384C6A;
border-color: #384C6A;
right:0px;
}
<div class="service-blocks">
<ul>
<li>
<h2>Service 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin, ligula quis convallis accumsan, ipsum ex lobortis risus, a malesuada orci turpis vel leo. Fusce sit amet arcu est. Ut mi nunc, vestibulum eu urna sed, blandit euismod est. Aliquam ut gravida orci. Sed varius iaculis diam, efficitur rutrum massa blandit sed. Nam in odio ornare, fringilla ex in, dapibus tortor. Aliquam aliquet ac dui sit amet fermentum.</p>
<span class="button-container">
Enquire
Learn More
</span>
</li>
<li>
<h2>Service 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin, ligula quis convallis accumsan, ipsum ex lobortis risus, a malesuada orci turpis vel leo. Fusce sit amet arcu est. Ut mi nunc, vestibulum eu urna sed, blandit euismod est. Aliquam ut gravida orci. Sed varius iaculis diam, efficitur rutrum massa blandit sed. Nam in odio ornare, fringilla ex in, dapibus tortor. Aliquam aliquet ac dui sit amet fermentum.</p>
<span class="button-container">
Enquire
Learn More
</span>
</li>
<li>
<h2>Service 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin, ligula quis convallis accumsan, ipsum ex lobortis risus, a malesuada orci turpis vel leo. Fusce sit amet arcu est. Ut mi nunc, vestibulum eu urna sed, blandit euismod est. Aliquam ut gravida orci. Sed varius iaculis diam, efficitur rutrum massa blandit sed. Nam in odio ornare, fringilla ex in, dapibus tortor. Aliquam aliquet ac dui sit amet fermentum.</p>
<span class="button-container">
Enquire
Learn More
</span>
</li>
</ul>
</div>
Div should not be over Div with background image with divs inside, but for some reason the about div is displayed over the nav:
body {
margin: 0;
padding: 0;
/*background-color: blue;*/
}
.divider {
background-color: #be2b27;
width: 100%;
height: 100px;
position: absolute;
display: block;
padding: 0;
}
.divider h1 {
font-family: "Nexa Light";
font-size: 2em;
color: white;
text-align:left;
padding-left: 10px;
}
.lorem-text {
font-family: "Menlo";
font-size: 1.2em;
color: white;
}
.start-section {
margin-top: 30px;
/* position: absolute; */
padding-left: 20px;
padding-top: 20px;
}
#start-bg {
background-image: url(water.jpg);
background-color:#9abee1;
background-repeat: round;
height:100%;
position: absolute;
}
#home-head {
font-family: 'Nexa Light';
/* font-size: ; */
padding-top: 30px;
color: white;
}
.nav { }
<div id="start-bg">
<!--<div class="nav"...>...</div>-->
<div class="start-section">
<h1 id="home-head">Landing Page</h1>
<p class="lorem-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ornare est in maximus vestibulum.
Mauris eu tincidunt quam.<br> In commodo neque id tortor mattis, non consectetur ante tincidunt.
Nunc ultrices ultricies purus, id finibus justo eleifend sit amet.<br>
Sed in iaculis libero, et gravida nibh.
Proin mollis, nibh eu rhoncus scelerisque, orci ex posuere mi, id pharetra purus est suscipit sapien.
Aliquam fermentum dignissim ultricies. Cras vitae neque tincidunt, tristique neque at, ornare leo.<br>
Integer gravida lectus sed venenatis auctor. Vestibulum sed ligula eget dui ultrices luctus.<br>
Etiam dapibus auctor sollicitudin. Nam vel dui non lorem semper scelerisque. Donec sed condimentum mauris.
Maecenas ac enim sit amet orci sodales porta.
</p>
<img src="http://via.placeholder.com/350x150">
<img src="http://via.placeholder.com/350x150">
<img src="http://via.placeholder.com/350x150"><br>
<img src="http://via.placeholder.com/350x150">
<img src="http://via.placeholder.com/350x150">
<img src="http://via.placeholder.com/350x150"><br>
</div>
</div>
<div class="divider">
<h1>About</h1>
</div>
There must be something wrong with the positions or something or the fact that when the div has a background image it is not registered as holding any content so the about div is displayed above it.
What do I need to do?
I want the div to be displayed after the background image ends and stays there when I remove the images. If you need the nav html and css code i will give it to you.
#start-bg {
background-image: url(water.jpg);
background-color:#9abee1;
background-repeat: round;
height:100%;
position: absolute;
}
If you remove:
position: absolute;
Red bar go to bottom bottom of the page.
Aloha - I have been recreating this tutorial - [CSS Positioning][1] -
[1]: http://www.barelyfitz.com/screencast/html-training/css/positioning/ to really understand the tutorial. It's at step 7 in the tutorial that I have bumped into something that I can't figure out. In step 7 of the tutorial you will see that the text "id = div-1" sits above the "div-1a" which is floated left.
If you take a look at my code pen - http://codepen.io/DarrenHaynes/pen/gLoYpp/ - You will see that the text "id = div-1" is aligning to the right of the "div-1a". I am not expecting this since "div-1" is the parent of "div-1a". Thus I can't figure out how to get my codepen to replicate the tutorial.
My code on codepen:
HTML:
<div id="div-before">
id = div-before
</div>
<div id="div-1">
id = div-1
<div id="div-1a">
id = div-1a
<br>
<br> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.
</div>
<div id="div-1b">
id = div-1b<br><br> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan
augue ipsum id lorem.
</div>
<div id=div-1c>
id = div-1c
</div>
</div>
<div id="div-after">
id = div-after
</div>
CSS:
#div-before,
#div-after {
margin: 0 auto;
width: 400px;
font-size: 20px;
background-color: #8888DD;
padding: 2px 5px;
}
#div-1 {
position: relative;
margin: 0 auto;
width: 400px;
color: white;
padding: 20px 10px 10px 10px;
background-color: black;
}
#div-1a {
float: left;
width: 200px;
padding: 3px;
background-color: red;
}
#div-1b {
padding: 3px;
background-color: green;
}
#div-1c {
padding: 3px;
background-color: #33D;
}
You can wrap your heading for "div-1" around a 'p' tag:
<div id="div-before">
id = div-before
</div>
<div id="div-1">
<p>id = div-1</p>
<div id="div-1a">
id = div-1a
<br>
<br> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.
</div>
<div id="div-1b">
id = div-1b<br><br> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Nam mattis, arcu ut bibendum commodo, magna nisi tincidunt tortor, quis accumsan
augue ipsum id lorem.
</div>
<div id=div-1c>
id = div-1c
</div>
</div>
<div id="div-after">
id = div-after
</div>
CSS:
#div-before,
#div-after {
margin: 0 auto;
width: 400px;
font-size: 20px;
background-color: #8888DD;
padding: 2px 5px;
}
#div-1 {
position: relative;
margin: 0 auto;
width: 400px;
color: white;
padding: 20px 10px 10px 10px;
background-color: black;
}
#div-1a {
float: left;
width: 200px;
padding: 3px;
background-color: red;
}
#div-1b {
padding: 3px;
background-color: green;
}
#div-1c {
padding: 3px;
background-color: #33D;
}
Here's the Codepen: http://codepen.io/anon/pen/xRJNdZ
I was wondering if the layout I draw on the following image is possible using flexbox and this HTML structure:
<div class="box">
<img src="url..." alt="" />
<h5>Lorem Ipsum</h5>
<p>Lorem Ipsum Dolor Sit Amet...</p>
</div>
It would be great if this could be done with flexbox and without adding more boxes inside.
For fixed image width and height, it's possible. The main idea is in the following snippet.
.box {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: space-between;
height: 300px;
}
.img {
width: 300px; height: 300px;
}
h5, p {
/* 100% - image width - margin between */
width: calc(100% - 300px - 16px);
}
Since the height of the parent is the same as the height of the image, the content overflows and gets wrapped to the right. Then we have to manually set the width because it's otherwise going to 100% of the parent.
.box {
background-color: #ddd;
padding: 16px;
margin-bottom: 24px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 300px;
align-content: space-between;
}
.img {
background-color: #333;
color: #ddd;
width: 300px;
height: 300px;
}
h5, p {
padding: 0;
margin: 0;
background-color: #ccc;
/* 100% - image width - margin between */
width: calc(100% - 300px - 16px);
}
h5 {
font-size: 18px;
margin-bottom: 8px;
}
.box:nth-child(even) .img {
order: 3;
}
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus</p>
</div>
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem Ipsum Dolor Sit Amet...</p>
</div>
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a </p>
</div>
Full-height paragraph
You might want to extend your paragraph all the way to the bottom (maybe add some links there). It's easy to extend it so you can turn p into flexbox to snap something to the bottom, for example (this example not in the demo below, you can only notice this by the gray background).
.box {
/* ... */
justify-content: space-between;
}
p {
flex-grow: 1;
}
.box {
background-color: #ddd;
padding: 16px;
margin-bottom: 24px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 300px;
align-content: space-between;
justify-content: space-between;
}
.img {
background-color: #333;
color: #ddd;
width: 300px;
height: 300px;
}
h5, p {
padding: 0;
margin: 0;
background-color: #ccc;
/* 100% - image width - margin between */
width: calc(100% - 300px - 16px);
}
h5 {
font-size: 18px;
margin-bottom: 8px;
}
p {
flex-grow: 1;
}
.box:nth-child(even) .img {
order: 3;
}
<div class="box">
<div class="img"><img></div>
<h5>Version 2</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus</p>
</div>
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem Ipsum Dolor Sit Amet...</p>
</div>
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. </p>
</div>
Both versions above breaks when the text cannot fit (try changing browser window size).
Doesn't show all, but never breaks
You can set the max-height for the paragraph if you don't want it to break and clip the text which cannot fit with overflow: hidden.
p {
max-height: 250px;
overflow: hidden;
}
.box {
background-color: #ddd;
padding: 16px;
margin-bottom: 24px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 300px;
align-content: space-between;
justify-content: space-between;
}
.img {
background-color: #333;
color: #ddd;
width: 300px;
height: 300px;
}
h5, p {
padding: 0;
margin: 0;
background-color: #ccc;
/* 100% - image width - margin between */
width: calc(100% - 300px - 16px);
}
h5 {
font-size: 18px;
margin-bottom: 8px;
}
p {
flex-grow: 1;
}
.box:nth-child(even) .img {
order: 3;
}
p {
max-height: 250px;
overflow: hidden;
}
<div class="box">
<div class="img"><img></div>
<h5>Version 3</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus</p>
</div>
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem Ipsum Dolor Sit Amet...</p>
</div>
<div class="box">
<div class="img"><img></div>
<h5>Lorem Ipsum</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis cursus hendrerit. Suspendisse potenti. Aliquam posuere ex ut lacus euismod dictum. Proin et ligula posuere leo viverra tempor a in tellus. </p>
</div>
I am trying to implement a sticky footer with CSS using this: http://www.cssstickyfooter.com/using-sticky-footer-code.html .
I have almost got it working, but when having floats in my content container, I find that the footer will overlap a bit of the content.
This is the markup:
<div class="container" id="content-area">
<div class="module-content" id="mycontent">
<div class="menu">
<ul>
<li>
<a class="current-page" href="http://localhost/">1</a>
</li>
</ul>
</div>
<div class="module-content">
<div>
<p>Lorem ipsum dolor sit amet, consequat et metus, platea
posuere adipiscing porttitor dis amet ut. Turpis diam amet,
mollit commodo. Fusce vestibulum habitant, auctor vel ac
dui, nulla lacus hac, raesent euismod habitant eros massa
nulla. Justo dui, facilisis cras. Est ante maecenas
vehicula, etiam vestibulum mi lorem massa, sed nullam
suspendisse lectus ante purus gravida, iaculis urna pede
fermentum. Arcu id ligula arcu, erat vivamus quisque
quisque, tristique ipsum et. Sociis duis ut, morbi dolor
duis volutpat lacus viverra, scelerisque sodales sed, vel
nulla. Elit pede nullam ullamcorper consectetuer ac massa,
lobortis eget id dictumst et quis, nulla metus. Magnis id
id suscipit porttitor faucibus, felis commodo risus massa,
fusce tempus praesent aliquet sit vulputate tempor.</p>
</div>
</div>
</div>
</div>
<div class="container" id="footer">
<div class="container">
<p>Lorem ipsum dolor sit amet, consequat et metus, platea
posuere adipiscing porttitor dis amet ut. Turpis diam amet,
mollit commodo. Fusce vestibulum habitant, auctor vel ac dui,
nulla lacus hac,</p>
</div>
</div>
And the CSS:
html, body {
height: 100%;
}
#content-area {
min-height: 100%;
overflow: auto;
position: relative;
}
.container {
margin: 0 auto;
width: 985px;
}
#mycontent .menu {
float: left;
margin-right: 10px;
padding-top: 13px;
width: 100px;
}
#mycontent .module-content {
float: left;
width: 700px;
}
#footer {
color: red;
background: black;
opacity: 0.6;
height: 70px;
margin-top: -70px;
width: 100%;
clear: both;
}
And a fiddle of the above: http://jsfiddle.net/CfuAg/
And a picture of what's happening
Why is this happening and what are some ways to fix it? I tried adding a padding of 70px to #content-area, but it pushes the footer down by 70px and doesn't stick to the buttom of the window anymore.
Fixed! overflow: auto was assigned to the wrong element (it should be assigned to .module-content) and module-content should have a bottom-padding with a height of the footer:
html, body {
height: 100%;
}
#content-area {
min-height: 100%;
position: relative;
}
.container {
margin: 0 auto;
width: 985px;
}
#mycontent .menu {
float: left;
margin-right: 10px;
padding-top: 13px;
width: 100px;
}
#mycontent .module-content {
float: left;
width: 700px;
overflow: auto;
padding-bottom: 70px;
}
#footer {
color: red;
background: black;
opacity: 0.6;
height: 70px;
margin-top: -70px;
width: 100%;
clear: both;
}
I've modify your fiddle to make it works the way I understood what you're looking for.
I've remove the clear: both; and margin-top: -70px; and use instead the bottom property which I've set to 0
http://jsfiddle.net/CfuAg/4/
Hope this is what you looked for.