code pen
HTML
<div id="header">header</div>
<div id="body"><div id="content">content</div></div>
<div id="footer">footer</div>
CSS
#header {
background-color: red;
}
#body {
background-color: orange;
}
#content {
width: 500px;
margin: 0 auto;
background-color: yellow;
}
#footer {
background-color: blue;
}
body {
display: table;
height: 100%;
width: 100%;
}
#header,#footer,#body {
display: table-row;
height: 1px;
}
#body {
height: auto;
}
#content {
/* ??? */
}
html,body {
margin: 0;
padding: 0;
height: 100%;
}
This answer provides some good solutions when just the top-level div needs to be stretched, but in my scenario, I can get #body (orange bg) to stretch but I need #content (yellow) to stretch all the way down as well.
How can I do that?
Demo http://codepen.io/anon/pen/Bltbh
#header {
background-color: red;
}
#body {
background-color: orange;
height:100%;
}
#content {
width: 500px;
margin: 0 auto;
background-color: yellow;
}
#footer {
background-color: blue;
}
body {
display: table;
height: 100%;
width: 100%;
}
#header,#footer,#body {
display: table-row;
}
#header,#footer {
height:1px;
}
#body {
height: 100%;
}
#content {
height: 100%;
}
html,body {
margin: 0;
padding: 0;
height: 100%;
}
Related
Hi guys I am having a problem with my responsive CSS. It is working fine with max-width:321px but not when I try to do max-width:500px. I am trying to understand why and what I am doing wrong. Please help...
/*/Mobile MAINCSS/*/
img {
max-width: 100%;
height: auto;
}
#media screen and (max-width: 320px) {
/*/Nav and Header/*/
iframe {
width: 100%;
height: 700px;
}
body {
color: red;
}
#nav {
display: none;
width: 100%;
}
#logomain {
width: 100%;
height: auto;
display: none;
}
.logo {
display: none;
}
.logoright {
display: none;
}
.mobile-number {
display: block;
text-align: center;
background:#333399;
}
.mobile-number a:link {
color: red;
text-decoration: none;
}
.mobile-number a:visited {
color: red;
text-decoration: none;
}
#head_wrap {
width: 100%;
height: auto;
}
#head {
width: 100%;
height: auto;
}
/*/Mobile Navigation/*/
#mobilenav {
display: block;
margin: 0 auto;
width: 100%;
height: auto;
background: #333399;
color: white;
font-size: 18px;
text-align: center;
}
.mobile ul {
display: inline;
margin: 0 auto;
width: 100%;
height: auto;
}
.mobile ul li {
display: inline-block;
padding: 10px;
}
.mobile a:link {
color: white;
text-decoration: none;
font-weight: bold;
text-shadow: 1px 1px 1px black;
border-radius: 5px 5px 5px 5px;
padding: 5px;
}
.mobile a:visited {
color: white;
}
}
/*/Content/*/
#content {
width: 100%;
height: auto;
}
#content_wrapper {
width: 100%;
height: auto;
}
#bizmain {
width: 100%;
height: auto;
}
.bizexpress {
float: none;
}
.bizpro {
float: none;
}
.pro {
float: none;
}
/*/Footer/*/
#footer {
width: 100%;
height: auto;
}
/*/Additional Updates 02/28/2015/*/
.main-right {
width: 100%;
height: auto;
text-align: center;
}
.main-left {
width: 100%;
height: auto;
float: none;
text-align: center;
}
.form {
width: 100%;
height: auto;
}
.form-control {
width: 50%;
}
.input-group-addon {
font-size: inherit;
}
/*/Website Design/*/
.evoke {
width: 100%;
height: auto;
}
.evokeemotions {
width: 100%;
height: auto;
}
.resource1 {
float: none;
text-align: center;
}
.resource2 {
float: none;
text-align: center;
}
.resource3 {
float: none;
text-align: center;
}
}
#media screen and (max-width: 500px)
{
}
#media screen and (max-width: 320px)
{
}
You are right no problem please. place 500px Css above 300px
I am working on a fluid grid (DreamWeaver CC) site. I have a header-Wrapper div containing stacked elements using z-index. I am now trying to add a div after the header-Wrapper but this div is floating behind the header-Wrapper. This is my first time working with z-index so I'm rather flummoxed.
I have tried position and display css elements for the mobileNav div and also tried to use a height element for the header-wrapper. Nothing. the mobileNav div seems to be ignoring the header-Wrapper altogether and acting like it is the first div in the gridContainer.
Thanks for your help
site: miki.nantucket.net/redac-2.php
html
<body>
<div class="gridContainer clearfix">
<div id="header-wrapper" class="fluid">
<div id="rotation" class="fluid "><?php include $_SERVER['DOCUMENT_ROOT']."/includes/layout/rotations.php" ?></div>
<div id="Weather" class="fluid "><?php include $_SERVER['DOCUMENT_ROOT']."/includes/layout/weather.php" ?></div>
<div id="Navigation" class="fluid "><ul>
<li>Nav1</li>
<li>Nav2</li>
<li>Nav3</li>
<li>Nav4</li>
<li>Nav5</li>
<li>Nav6</li>
<li>This is not styled yet</li>
</ul></div>
</div><!--end header-wrapper-->
<div id="mobileNav" class="fluid">This is the content for Layout Div Tag "mobileNav"</div>
</div>
</body>
CSS
.fluid {
clear: both;
margin-left: 0;
width: 100%;
float: left;
display: block;
}
.fluidList {
list-style:none;
list-style-image:none;
margin:0;
padding:0;
}
/* Mobile Layout: 480px and below. */
.gridContainer {
margin-left: auto;
margin-right: auto;
width: 92.625%;
padding-left: 0;
padding-right: 0;
clear: none;
float: none;
background-color:#FBFAF6;
}
#header-wrapper {
position:relative;
width: 100%;
padding:0;
margin:0;
}
#rotation {
position:absolute;
z-index:1;
}
#Navigation {
display:none;
width: 100%;
}
#Weather {
text-align:right;
font-size:13px;
padding:5px 0px 10px 0px;
position:absolute;
z-index:50;
top:0px;
left:0;
background: #4b829f;
background: rgba(75,134,159, .8);
color: #ffffff;
}
#mobileNav {
position:relative;
}
.zeroMargin_mobile {
margin-left: 0;
}
.hide_mobile {
display: none;
}
/* Tablet Layout: 481px to 768px. Inherits styles from: Mobile Layout. */
#media only screen and (min-width: 481px) {
.gridContainer {
width: 93.4166%;
padding-left: 0;
padding-right: 0;
clear: none;
float: none;
margin-left: auto;
}
#header-wrapper {
}
#rotation {
}
#Navigation {
display:block;
position:absolute;
z-index:100;
top:49px;
left:0;
background: #4b8a9f;
background: rgba(75,134,159, .8);
color: #ffffff;
width: 23.7288%;
}
#Weather {
}
#mobileNav {
}
.hide_tablet {
display: none;
}
.zeroMargin_tablet {
margin-left: 0;
}
}
/* Desktop Layout: 769px to a max of 1232px. Inherits styles from: Mobile Layout and Tablet Layout. */
#media only screen and (min-width: 769px) {
.gridContainer {
width: 88.875%;
max-width: 1232px;
padding-left: 0;
padding-right: 0;
margin: auto;
clear: none;
float: none;
margin-left: auto;
}
#header-wrapper {
}
#rotation {
}
#Navigation {
display:block;
position:absolute;
z-index:100;
top:49px;
left:0;
background: #4b8a9f;
background: rgba(75,134,159, .8);
color: #ffffff;
width: 17.7215%;
}
#Weather {
}
#mobileNav {
}
.zeroMargin_desktop {
margin-left: 0;
}
.hide_desktop {
display: none;
}
}
CSS for included responsive slider
/*responsive hero slider*/
.rslides {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.rslides li {
-webkit-backface-visibility: hidden;
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}
.rslides li:first-child {
position: relative;
display: block;
float: left;
}
.rslides img {
display: block;
height: auto;
float: left;
width: 100%;
border: 0;
}
.caption {
position: absolute;
display: block;
bottom: 0;
left: 0;
right: 0;
padding: 10px;
margin:0;
text-align: center;
background: #4b8a9f;
background: rgba(75,134,159, .8);
color: #ffffff;
font-size:18px;
font-stretch:expanded;
}
Thank you. Due to the various elements, I do need the absolute positioning but your comment about allowing for the space in the header-wrapper gave me an idea. I put an image into the header-wrapper, fiddled around with the z-index property here and there. Probably not the most elegant way to do it but it's working!
Thank you.
html
<div class="gridContainer clearfix">
<div id="header-wrapper" class="fluid">
<div id="rotation" class="fluid "><?php include $_SERVER['DOCUMENT_ROOT']."/includes/layout/rotations.php" ?></div>
<div id="Weather" class="fluid "><?php include $_SERVER['DOCUMENT_ROOT']."/includes/layout/weather.php" ?></div>
<div id="Navigation" class="fluid "><ul class="navBump">
<li>Nav1</li>
<li>Nav2</li>
<li>Nav3</li>
<li>Nav4</li>
<li>Nav5</li>
<li>Nav6</li>
<li>This is not styled yet</li>
</ul></div>
<div id="LogoWrapper" class="fluid "><div id="Logo" class="fluid "><img src="images/sitewide/Logo.png"></div><div id="LogoTag" class="fluid "><?php include $_SERVER['DOCUMENT_ROOT']."/includes/layout/logtag.php" ?></div></div>
<img src="images/rotations/redac2/image1a.jpg">
</div><!--end header-wrapper-->
<div id="mobileNav" class="fluid">This is the content for Layout Div Tag "mobileNav"</div>
</div>
CSS
.fluid {
clear: both;
margin-left: 0;
width: 100%;
float: left;
display: block;
}
.fluidList {
list-style:none;
list-style-image:none;
margin:0;
padding:0;
}
/* Mobile Layout: 480px and below. */
.gridContainer {
margin-left: auto;
margin-right: auto;
width: 92.625%;
padding-left: 0;
padding-right: 0;
clear: none;
float: none;
background-color:#FBFAF6;
}
#header-wrapper {
position:relative;
width: 100%;
padding:0;
margin:0;
}
#header-wrapper img {
position:relative;
z-index:1;
}
#rotation {
position:absolute;
top:0;
left:0;
z-index:5;
margin-left: 0;
width: 100%;
}
#Navigation {
display:none;
width: 31.0344%;
margin-left: 0;
}
#Weather {
text-align:right;
font-size:13px;
padding:5px 0px 10px 0px;
position:absolute;
z-index:50;
top:0px;
left:0;
background: #4b829f;
background: rgba(75,134,159, .8);
color: #ffffff;
margin-left: 0;
width: 100%;
}
#mobileNav {
z-index:0;
width: 100%;
margin-left: 0;
}
#LogoWrapper {
position:absolute;
top:0;
left:0;
z-index:1000;
}
#Logo {
}
#LogoTag {
font-size:12px;
color:#797979;
}
.zeroMargin_mobile {
margin-left: 0;
}
.hide_mobile {
display: none;
}
/* Tablet Layout: 481px to 768px. Inherits styles from: Mobile Layout. */
#media only screen and (min-width: 481px) {
.gridContainer {
width: 93.4166%;
padding-left: 0;
padding-right: 0;
clear: none;
float: none;
margin-left: auto;
}
#header-wrapper {
}
#rotation {
width: 100%;
margin-left: 0;
}
#Navigation {
display:block;
position:absolute;
z-index:100;
top:49px;
left:0;
background: #4b8a9f;
background: rgba(75,134,159, .8);
color: #ffffff;
width: 23.7288%;
margin-left: 0;
}
#Weather {
width: 100%;
margin-left: 0;
}
#mobileNav {
margin-left: 0;
width: 100%;
}
#LogoWrapper {
}
#Logo {
}
#LogoTag {
}
.hide_tablet {
display: none;
}
.zeroMargin_tablet {
margin-left: 0;
}
}
/* Desktop Layout: 769px to a max of 1232px. Inherits styles from: Mobile Layout and Tablet Layout. */
#media only screen and (min-width: 769px) {
.gridContainer {
width: 88.875%;
max-width: 1232px;
padding-left: 0;
padding-right: 0;
margin: auto;
clear: none;
float: none;
margin-left: auto;
}
#header-wrapper {
}
#rotation {
width: 100%;
margin-left: 0;
}
#Navigation {
display:block;
position:absolute;
z-index:100;
top:49px;
left:0;
background: #4b8a9f;
background: rgba(75,134,159, .8);
color: #ffffff;
width: 24.0506%;
margin-left: 0;
}
#Weather {
width: 100%;
margin-left: 0;
}
#mobileNav {
width: 100%;
margin-left: 0;
}
#LogoWrapper {
}
#Logo {
}
#LogoTag {
}
.zeroMargin_desktop {
margin-left: 0;
}
.hide_desktop {
display: none;
}
}
rotating images CSS
.rslides {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.rslides li {
-webkit-backface-visibility: hidden;
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}
.rslides li:first-child {
position: relative;
display: block;
float: left;
}
.rslides img {
display: block;
height: auto;
float: left;
width: 100%;
border: 0;
}
.caption {
position: absolute;
z-index:25;
display: block;
bottom: 0;
left: 0;
right: 0;
padding: 10px;
margin:0;
text-align: center;
background: #4b829f;
background: rgba(75,134,159, .8);
color: #ffffff;
font-size:18px;
font-stretch:expanded;
}
Your #mobileNav is appearing behind all of the #header-wrapper content because all of the #header-wrapper content is using position: absolute;. Absolutely positioned elements like #Weather and #Navigation are removed from the flow of the document as if they were never there. You probably just want to float them into their positions, but if absolute positioning is required, then you'll need to account for them with some space in the parent element.
I'm building a site that has 3 sections in the middle that all sit side by side.
The center box is where the page's content will be shown and therefore will adjust to fit.
The issue is that the #leftnav and #rightnav should adjust to the height of the parent container, this would work when the #centralcontent height is adjusted by its content (text and so on) - how is this best done?
Please see the code in action: http://jsfiddle.net/AlexHighHigh/WJKR5/
Here's the HTML
<div id="pagecontainer">
<div id="header"><img src="http://s23.postimg.org/u4fk339vf/design_1_01.jpg" width="850" height="308" alt="logo" /></div>
<div id="centralcontainer">
<div id="leftbar"> </div>
<div id="centralcontent">
<p> </p>
<p> </p>
<p> </p>
</div>
<div id="rightbar"> </div>
</div>
<div id="footer"><img src="http://s23.postimg.org/w6g1hc7uj/design_1_05.jpg" width="850" height="30" alt="footer" /><br />
© 2014 Surrey Hills Fox Control</div>
</div>
..and here's the CSS
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #161616;
margin: 0;
padding: 0;
color: #fff;
}
#pagecontainer {
height: 100%;
width: 850px;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout. It is not needed if you set the .container's width to 100%. */
}
#header {
height: 308px;
background-color:#66CCFF;
}
#centralcontainer {
height: auto;
width: 850px;
}
#leftbar {
float: left;
width: 85px;
min-height: 100%;
background-image:url(http://s23.postimg.org/69md4q46z/design_1_02.jpg);
bottom: 0;
background-color:#66CCFF;
}
#centralcontent {
float: left;
height: auto;
width: 680px;
background-color:#FFF;
}
#rightbar {
float: left;
width: 85px;
min-height: 100%;
background-image:url(http://s23.postimg.org/lxnkbijsr/design_1_04.jpg);
bottom: 0;
background-color:#66CCFF;
}
#footer {
float: left;
width: 850px;
height: 150px;
text-align:center;
}
Any help appreciated, thanks in advance!
Alex
add height: 100%; to body and it would work
why it works?? your #pagecontainer has height:100%, so it would set 100% of the parent of pagecontainer, which is body, but you have not set height of body
EDIT
I see you used floats, if its fine with you, use display :table as it helps you avoid clearing the floats and other stuffs
see demo
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #161616;
margin: 0;
padding: 0;
color: #fff;
height : 100%;
}
#pagecontainer {
height: 100%;
width: 850px;
margin: 0 auto;
/* the auto value on the sides, coupled with the width, centers the layout. It is not needed if you set the .container's width to 100%. */
}
#header {
height: 308px;
background-color:#66CCFF;
border:1px solid #FFF;
}
#centralcontainer {
min-height: 100%;
width: 850px;
display:table;
}
#leftbar {
display:table-cell;
width: 85px;
min-height: 100%;
height:100%;
background-image:url(http://s23.postimg.org/69md4q46z/design_1_02.jpg);
bottom: 0;
background-color:#66CCFF;
border:1px solid #FFF;
}
#centralcontent {
display:table-cell;
height: 100%;
width: 680px;
<!-- background-color:#FFF;
/*commented*/
-->
}
#rightbar {
display:table-cell;
width: 85px;
min-height: 100%;
background-image:url(http://s23.postimg.org/lxnkbijsr/design_1_04.jpg);
background-color:#66CCFF;
}
#footer {
float: left;
width: 850px;
height: 150px;
text-align:center;
}
Hi you probably should use common fix for same columns height
In you case just add overflow:hidden; to #centralcontainer and to
#leftbar,#rightbar
add
padding-bottom:9000px;
margin-bottom:-9000px;
Please look to
Seems working sample
Working Demo
I added a couple of other things to your CSS for better cross-browser compatibility but you can remove it if you really want.
CSS:
html, body {
margin: 0;
padding: 0;
zoom: 1;
height: 100%;
width: 100%;
}
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #161616;
color: #fff;
}
*:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
clear: both;
display: table;
}
#centralcontainer div {
outline: 3px solid red;
}
#pagecontainer {
height: 100%;
width: 850px;
margin: 0 auto;
}
#header {
height: 308px;
background-color:#66CCFF;
}
#centralcontainer {
width: 850px;
position: relative;
}
#leftbar {
position: absolute;
width: 85px;
background-color:#66CCFF;
background-image:url(http://s23.postimg.org/69md4q46z/design_1_02.jpg);
bottom: 0;
top: 0;
left: 0;
}
#centralcontent {
left: 85px;
position: relative;
height: auto;
width: 680px;
background-color:#FFF;
}
#rightbar {
position: absolute;
width: 85px;
background-color:#66CCFF;
background-image:url(http://s23.postimg.org/lxnkbijsr/design_1_04.jpg);
bottom: 0;
top: 0;
right: 0;
}
#footer {
float: left;
width: 850px;
height: 150px;
text-align:center;
}
I need help to fix the next layout, because:
It doesnt look right for IE
The footer doesnt stay at bottom when #columns content grows up
I need to make the #column container 100% min-height with small content
Thanks in advance!
This is my code:
<style>
* {
margin: 0;
padding: 0;
}
body, html {
background: silver;
height: 100%;
}
#header {
min-width: 1000px;
width: 100%;
height: 40px;
background: red;
}
#columns {
width: 1000px;
background: white;
margin: 0 auto;
padding-bottom: 40px;
border: 1px solid black;
}
#footer {
position: absolute;
bottom: 0;
min-width: 1000px;
width: 100%;
height: 40px;
background: black;
}
<body>
<div id="header"></div>
<div id="columns"></div>
<div id="footer"></div>
</body>
Try this (edited) :
JSFiddle: http://jsfiddle.net/NeCc3/14/
* {
margin: 0;
padding: 0;
}
body, html {
background: silver;
height:100%
}
#header {
width: 100%;
height: 40px;
background: red;
}
#columns{
min-height:100%;
width: 1000px;
background: white;
margin: 0 auto;
padding-bottom: 40px;
border: 1px solid black;
}
#footer {
width: 100%;
height: 40px;
background: black;
}
Having some issues trying to create a fixed header layout for this jsfiddle:
http://jsfiddle.net/4xk4D/107/
Basically, I'd like the id element app-header-container to be fixed on the page.
I used this article as a reference but no luck yet!
NOTE: I am using SCSS in the jsfiddle.
#header {
top:0;
width:100%;
position:fixed;
background-color:#FFF;
}
#content {
position:static;
margin-top:100px;
}
Trying to modify your css:
#app-header-wrapper
{
width: 1024px;
margin: 10px auto;
background-color: pink;
}
#app-header-container
{
}
#app-main-nav
{
background-color: pink;
}
#app-header
{
height: 93px;
background-color: blue;
}
#app-access
{
background-color: green;
}
#app-content-container
{
width: 1024px;
margin: 10px auto;
background-color: red;
}
#app-content
{
float: left;
width: 739px;
background-color: yellow;
}
#app-sidebar
{
float: right;
width: 275px;
background-color: orange;
}
#app-footer
{
margin: 0 auto;
width: 1024px;
height: 50px;
background-color: pink;
}
.clearfix:after
{
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
font-size: 0;
}
Or just try using css grid for layouting. One of them http://1kbgrid.com/
#app-header-wrapper {
width: 1024px;
margin: 10px auto;
background-color: pink;
#app-header-container {
#app-access {
background-color: green;
}
#app-header {
height: 93px;
background-color: blue;
}
#app-main-nav {
background-color: pink;
}
}
}
You can not nest CSS that way. Much of the CSS is being ignored due to how you've got it nested and sub nested between brackets. Markup shoul dbe selector { property } or selector, selector, selector { property }