CSS Sticky footer with 100% width - css

I'm trying to implement a sticky footer having a 100% of width. It should be stick on the bottom of the page, but not overlapping the page content div.
I'm using the page layout identical to this example:
http://peterned.home.xs4all.nl/examples/csslayout1.html
As you can see, the footer has the same width of div#container.
But I want to stretch the footer up to 100% width, whilst the page content stays centered and keeps stretching in height when resizing the browser.
How can I do that?

try this
click le link to see new result
http://jsfiddle.net/n6u3e/
/**
* 100% height layout with header and footer
* ----------------------------------------------
* Feel free to copy/use/change/improve
*/
html,body {
margin:0;
padding:0;
height:100%; /* needed for container min-height */
background:gray;
font-family:arial,sans-serif;
font-size:small;
color:#666;
}
h1 {
font:1.5em georgia,serif;
margin:0.5em 0;
}
h2 {
font:1.25em georgia,serif;
margin:0 0 0.5em;
}
h1, h2, a {
color:orange;
}
p {
line-height:1.5;
margin:0 0 1em;
}
div#container {
position:relative; /* needed for footer positioning*/
margin:0 auto; /* center, not in IE5 */
width:750px;
background:#f0f0f0;
height:auto !important; /* real browsers */
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
}
div#header {
padding:1em;
background:#ddd url("../csslayout.gif") 98% 10px no-repeat;
border-bottom:6px double gray;
}
div#header p {
font-style:italic;
font-size:1.1em;
margin:0;
}
div#content {
padding:1em 1em 5em; /* bottom padding for footer */
}
div#content p {
text-align:justify;
padding:0 1em;
}
div#footer {
background:#ddd;
border-top:6px double gray;
}
div#footer p {
padding:1em;
margin:0;
}
#barco{
width:750px;
margin:auto;
}

Related

HTML, CSS Fullscreen Carousel

I am having issues with my code for my CSS carousel. I have Javascript just switching some of the classes so I know that is not an issue. My issue is that the height of the image is not scaling the way I would like it to. I want this site to be responsive and the first step is making this fullscreen carousel working. I am making a one pager so I would like to be able to scroll down past the carousel, but when the page initially loads I would like it to show the fullscreen carousel and the NAV bar. The NAV bar is fine right now but the carousel is having issues with the height scaling. As the browser window gets smaller the image will become smaller than the screen, thus it is not fullscreen anymore. I don't mind if some of the image is cut off but I would like the carousel to always be full screen unless the user scrolls down or clicks on a link to an anchor point.
Here is the CSS:
/* General */
*{
box-sizing:border-box;
}
html {
margin:0;
padding:0;
width:100vw;
/* min-height:100vh;
*/
}
body {
width:100%;
max-width:100%;
min-height:100vh;
margin:0;
padding:60px 0 0 0;
background-color:#333333;
font-family: 'Varela Round', sans-serif;
}
/* ***Menu CSS*** */
/* -------------------------------------------
Nav bar
------------------------------------------- */
nav {
background-color:rgba(22,22,22,0.7);
position:fixed;
top:0;
left:0;
right:0;
height: 60px;
text-align:center;
z-index:2;
}
nav:after {
content:"";
position:absolute;
top:0;
right:0;
width:0;
height:0;
border-style:solid;
border-width:0 60px 60px 0;
border-color:transparent #50C0C0 transparent transparent;
}
nav a {
text-decoration:none;
color:initial;
}
nav .navButton {
display:inline-block;
color:#50C0C0;
line-height:60px;
padding:0 50px;
position: relative;
}
nav .navButton:after {
content:"";
transition:width .5s, left .5s;
-webkit-transition:width .5s, left .5s;
-moz-transition:width .5s, left .5s;
-o-transition:width .5s, left .5s;
width:0;
left:50%;
}
nav .navButton:hover:after {
content:"";
left:20%;
height:1.5px;
width:60%;
background-color:#50C0C0;
position:absolute;
bottom:0;
box-shadow: 0 -3px 15px #ffffff;
}
/* div around all nav buttons */
nav .buttonWrapper {
display:inline-block;
text-align:center;
}
/* ***Carousel css*** */
/* -------------------------------------------
Carousel
------------------------------------------- */
.carousel {
width:100%;
position:relative;
height: 100%;
}
.carousel .imageContainer {
position:absolute;
transition:width .5s;
-webkit-transition:width .5s;
-moz-transition:width .5s;
-o-transition:width .5s;
overflow:hidden;
width:100%;
}
.carousel .imageContainer img {
width: 100vw;
min-width:100%;
min-height:100%;
}
.carousel .imageContainer.closed {
width:0;
}
.carousel .imageContainer.open {
width:100%;
}
.carousel .imageContainer.fromRight {
right:0;
}
.carousel .imageContainer.fromLeft {
left:0;
}
in order to keep your carousel full screen you need to set the width = 100% ( of course ), and have the height at 100vh, this will maintain the height of the carousel 100% height of the viewport. Should do the trick.
#carousel{
position:relavite;
display:block;
width:100%;
margin-top:70px;
height:calc(100vh - 70px);
background:#000 url('http://lorempixel.com/1100/1100/sports/') no-repeat top center;
background-size:cover;
z-index:1;
}
*you may consider to set the images on of your carousel as background images and set the size to cover. On my example, i subtracted the height of the nav, so the carousel can be rest of the height and pushed it down with margin.
you can preview here:
https://plnkr.co/edit/4AsQ3PoM0Ze2gOFENsVG?p=preview

Divs move auto of the poisition on resize CSS

i'm having a problem and i can't find a solution that fits, i'm have two divs and the second one moves out to below of the 1º one when i resize below 800px (1ºdiv width + 2ºdiv width). What i want it's to fix the elements (not position 'fixed'), but i want them side to side no matter what, like in the facebook page or google, when i resize they stay in same place even if they go 'outside' the window. http://jsfiddle.net/VLt9m/. Thanks in advance.
#wrapper {
padding:92px 0 0 0;
width:100%;
float:left;
}
#content a {
text-decoration: none;
}
#block1{
background-color: #FFC374;
width:400px;
height:400px;
margin:0;
float: left;
position: relative;
}
#b1Title{
width:400px;
height:100px;
margin:0;
background-color: #FFD190;
opacity: 0.8;
position: absolute;
}
#b1Title h1{
color: #222;
font-size: 200%;
margin: 8% 0 0 12%;
}
#block2{
background-color:#449DCC;
width:400px;
height:400px;
margin:0;
float: left;
position: relative;
}
#b2Title{
width:400px;
height:100px;
margin:0;
background-color:#80B7D7;
opacity: 0.8;
position: absolute;
}
#b2Title h1{
color: #222;
font-size: 200%;
margin: 8% 0 0 12%;
}
If you wish, you can do it with media query. But, here is a quick fix with max-width
Working Demo
Add this to block
max-width:400px;
width:50%;
And this to title
max-width:400px;
width:100%;
Update
Give fixed width to wrapper
Working Demo
#wrapper {
padding:92px 0 0 0;
width:800px;
float:left;
}
If my guess is right, then you need to give min-width:800px; to Wrapper.
#wrapper{
padding:92px 0 0 0;
min-width:800px;
float:left;
overflow:auto;}
See here

css background image before and after h1 tag

I have to style all h1 tags to have an image before and after h1 text.
I know how to add image before, but do not know how to add both.
CSS (styling h1 to have image before text)
h1 {
background-image: url('images/h_ltr.png');
background-position: left center;
background-repeat: no-repeat;
text-align: center;
font-size: 22px;
font-weight: bold;
color: #5d5d5d;
}
You can use the :before and :after css selectors.
h1:before {
background-color: green;
padding: 0 20px;
content: " ";
}
h1:after {
background-color: red;
padding: 0 20px;
content: " ";
}
<h1>Test</h1>
You can also use multiple background images. In this example, I set background images for the left, centre and right bg images:
h1, h2, h3, h4, h5, h6 {
background-image: url("images/heading-bg-left.png"), url("images/heading-bg-right.png"), url("images/heading-bg-center.png"); /* set each bg image */
background-position: left center, center center, right center; /* set position of each bg image */
background-repeat: no-repeat, no-repeat, repeat-x; /* set repeat of each bg image */
padding: 0 92px; /* 92px is the width of my left and right bg images */
height: 120px; /* 120px is the height of each bg image */
line-height: 120px; /* ditto */
}
The code is fairly self-explanatory, but basically I have used three background-images with three background-positions and three background-repeats.
Note that the image are rendered in reverse order. So, in my example, the left and right images will be drawn on top of the centre image.
<style>
.container{
width:900px;
margin:0 auto;
position:relative;
overflow:hidden;
text-align:center;
}
h1{
font-size:20px;
display:inline-block;
position:relative;
padding:0 40px;
}
h1:after{
height:1px;
position:absolute;
content:"";
background:green;
top:10px;
width:500%;
right:-500%;
}
h1:before{
height:1px;
position:absolute;
content:"";
background:red;
top:10px;
width:500%;
left:-500%;
}
</style>
<div class="container">
<h1>1</h1>
</div>

Mobile web app, styling in percentages; I can't get height to work

I am building a mobile app for a band and obviously want it to display well in all the plethora of handsets out there today. I built it at first for my own device and it looks and works great, so now I am reworking it in percentages so that it works in all devices.
I have a slider (jquerytools) going on and if i set width to 100% then it is perfectly wide in my iphone and my ipad... success, however I am not having any luck with height. It seems to only accept a height in px. If i set a height in percent it just doesn't display.
any ideas?
Updated CSS:
#header{
width:100%;
position:relative;
z-index: 20;
box-shadow: 0 0 10px white;
}
.scrollable {
position:relative;
overflow:hidden;
width: 100%;
height: 100%;
box-shadow: 0 0 20px purple;
/* height:198px; */
z-index: 20;
}
.scrollable .items {
/* this cannot be too large */
width:1000%;
position:absolute;
clear:both;
box-shadow: 0 0 30px green;
}
.items div {
float:left;
width:10%;
height:100%;
}
/* single scrollable item */
.scrollable img {
float:left;
width:100%;
height: auto;
/* height:198px; */
}
/* active item */
.scrollable .active {
border:2px solid #000;
position:relative;
cursor:default;
}
if your element mustn't be position:relative, i'd do like that
.scrollable {
position:absolute; // instead of relative
overflow:hidden;
width: 100%;
top:0;
bottom:0;// instead of height: 100%;
box-shadow: 0 0 20px purple;
/* height:198px; */
z-index: 20;
}
basically I defined the position as absolute, and added the fact the element begins at zero from top and at zero from bottom, which would be equivalent to height:100%;

How can I keep an image aligned to the bottom left of my page?

I am trying to keep an image attached to the bottom-left of my page, but unlike How to keep background image on bottom left even scrolling, I do not want the image to follow the user as they scroll.
I have a feeling it has something to do with making #wrap fill up the entire window, but I can't seem to figure out how.
I am using normalize, with this code appended to the style sheet:
body {
background-image:url('/img/graph-paper3.png');
background-repeat:repeat;
}
#container {
width:960px;
margin:0 auto;
}
#sidebar {
float:left;
width:310px;
padding:10px;
}
#main {
float:right;
width:610px;
padding:0 10px 10px 10px;
margin-top: 40px;
background-image:url('/img/top.png');
background-repeat:no-repeat;
background-position:top center;
}
#paper {
margin:40px 0 147px 0;
padding:20px;
background-color:#ffffff;
min-height:400px;
}
#footer {
clear:both;
padding:5px 10px;
}
#footer p {
margin:0;
}
#wrap {
background-image:url('/img/jeremy-david.png');
background-repeat:no-repeat;
background-position:left bottom;
}
You can see the code in action here: http://www.jeremydavid.com.
How about:
.bottom-image{
position: absolute;
bottom: 0px;
left: 0px;
}
This will position the image absolutely to the page. (Make sure it isn't a child of another absolute or relative or fixed positioned element).
Use
.bottom-image {
max-width: //some %
z-index: -100;
position: fixed;
bottom: 0px;
left: 0px;
}
You can also use
#wrap{ //your main #wrap container
background: url('/img/jeremy-david.png') no-repeat bottom left;
}

Resources