having issues with css element placement - css

The grey element, a div with id of #banner is not meant to be sticking out, I gave all the elements inside the div containing the welcome to fusion box, red element, and banner a min-height which adds up to all the min-heights of the elements inside it (welcome to fusion cube, red element, banner).
Basically it's not meant to stick out and I just can't figure out why it is sticking out.
JsFiddle
Not really something productive to ask but I can't figure it out and it's stressful
#main-wrapper{
width: 80%;
height: calc(75.5% - 10px);
margin: 10px auto 0;
min-height: 250px;
}
#page-title {
height: 7%;
font-size: 1.8em;
text-align: center;
padding: 1px 0 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
min-height: 35px;
}
#content-wrapper {
background: red;
height: 83%;
min-height: 160px;
}
#page-messages {
width: 100%;
height: 20%;
overflow: auto;
}
#banner {
height: 10%;
display: inline-block;
background: grey;
min-height: 55px;
}
footer {
height: 8%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 0.5%;
margin: 20px 0 0;
width: 100%;
display: block;
}

you defined #banner as an inline-block - is that intention? (= not spanning the whole width?). Your fiddle looks quite different from the screenshot you posted...
try making its position: absolute and bottom: 0px;, and give the parent element (#main-wrapper) position: relative, and also a margin-bottom as high as #banner, which prevents content to be hidden by #banner.
(edited, wrong name for parent element)

Related

Angular 2 component with sticky header & footer and dynamic content height

I'm trying to build a component with sticky header and footer, while the content height is dynamic. I tried to use the FIDDLE example (at the bottom of this post), but the behavior is not the same. When I resize the screen, the window just run over the footer/header.
This is what I'm trying to achieve:
The FIDDLE code example:
http://jsfiddle.net/PGC7D/18/
html,body
{
height: 100%;
}
header,footer,div
{
width: 100%;
}
.container
{
height: 100%;
background: pink;
margin: -64px 0 -30px;
padding: 64px 0 30px;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#content {
overflow:auto;
height:100%;
}
.block
{
width: 50%;
height: 50%;
display: inline-block;
border: 1px solid yellow;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-align: center;
}
header
{
height: 64px;
background: purple;
position: relative;
z-index:1;
}
footer
{
height: 30px;
background: gray;
position: relative;
z-index:1;
}

Fixed position element inheriting width of flex item

I'm building out a UI that requires a fixed position/sticky element at the bottom of the viewport with a width constrained by a main content area. The main content area is optionally flanked by (sibling) left and/or right sidebars with fixed widths, so I'm using Flexbox to build the three column structure with flex-grow: 1 on the main content.
I've learned from #Marc Audet's accepted answer at How can I make a fixed positioned div inherit width of parent? that setting width: inherit on the fixed element is typically how to solve this problem, but it only seems to work when there's a specified width on its parent, which doesn't help me considering I need the main content area to fill the remaining width of the page.
Does anyone have any ideas for getting around this? Check out my Fiddle for the code/example. Any help would be appreciated!
CSS
html {
box-sizing: border-box;
font: 400 16px/1.45 'Source Code Pro';
}
*,
*:before,
*:after {
box-sizing: inherit;
margin: 0;
padding: 0;
border: 0;
outline: none;
overflow-x: hidden;
}
body {
background: #121;
color: #FEF;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
width: 100vw;
height: 100vh;
}
.container {
display: flex;
color: #fff;
height: -moz-fit-content;
height: -webkit-fit-content;
height: fit-content;
background: blue;
}
.left {
background: blue;
min-height: 100vh;
min-width: 150px;
flex-shrink: 0;
}
.middle {
background: green;
min-height: 100vh;
overflow: hidden;
width: calc(100vw - 400px);
padding-bottom: 60px;
flex-grow: 1;
flex-shrink: 0;
}
.middle .fixed-footer {
background: orange;
position: fixed;
bottom: 0;
width: 100vw;
width: inherit;
padding: 16px 0;
overflow-x: hidden;
}
.right {
background: blue;
min-height: 100vh;
min-width: 250px;
flex-shrink: 0;
}
#media screen and (min-width: 640px) {
html {
margin-left: calc(100vw - 100%);
margin-right: 0;
overflow-y: auto;
}
}
Added Star Wars ipsum content to demonstrate .middle's vertical flexibility and how .fixed-footer is stationary and is .middle's width.
DEMO

Text On top of darkened transparent background

So earlier, I was trying to figure out how to darken an image with transparency using CSS but when I figured that out, the new question came was how would I place text over that? This is what i have so far... http://jsfiddle.net/PXU6j/3/
<h1> Any Help Will Be appreciated </h1>
Use CSS positioning to draw content (such as text) over other content.
http://jsfiddle.net/j8592/27/
/* apply a natural box layout model to all elements */
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.container {
position: relative;
display: inline-block;
}
.container img {float: left;}
.foo-background {
background: rgba(0,0,0,0.5);
position:absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.foo-text {
position: absolute;
left: 0;
top:0;
width: 100%;
height: 100%;
color: #f2f2f2;
padding: 20px;
}

Stretching a content div (under a header) to full page length

I've been battling with this problem for a while and I'd like to ask advice if any of you can help.
I'm making a simple layout where I have a 120px high header and a content div under it. I'd like to stretch the content to the bottom of the page, but when I set the height to 100% it stretches over the page.
I have tried googling this plenty of times but none of the answers I've found help me or are too complex to understand.
My CSS is as follows:
* {
-ms-box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
height: 100%;
border: 5px solid red;
margin-bottom: -16px;
}
body {
background-color: lightblue;
height: 100%;
border: 5px solid blue;
margin: 0 0 -16px 0;
}
.wrapper {
display: block;
position: relative;
background-color: green;
width: 605px;
margin: auto;
height: 100%
}
.header {
display: inline-block;
background-color: blue;
height: 120px;
width: 450px;
text-align: center;
padding: 5px 0px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.content {
display: inline-block;
background-color: red;
padding: 10px 5px;
width: 450px;
height: 100%;
I've set borders to html and body just to see that I can stretch them properly, so please ignore those.
You can position the header absolute within the content div and set the top padding on the content div to the same height as the header.
JSFiddle
HTML
<div class="wrapper">
<div class="content">
<div class="header"></div>
</div>
</div>
CSS
.header {
position:absolute;
top:0;
left:0;
background-color: blue;
height: 120px;
width: 450px;
text-align: center;
padding: 5px 0px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.content {
display: inline-block;
background-color: red;
padding: 10px 5px;
width: 450px;
height: 100%;
padding-top:120px;
}
Set max-height: 100%; instead of height: 100%; which will not over-height the header height as it is defined height: 120px;

Auto adjust divs height to fill up the remaining space

I have 2 divs. I gave the first one a height of 70px and now I want the 2nd div to fill up the remaining space of the webpage. This should be relative to the first div. Below is my code: (The 2 divs are header and content)
* {
margin: 0px;
padding: 0px;
}
#header {
background-color: #1874CD;
width: 100%;
height: 70px;
}
#name {
color: #ffffff;
padding: 10px 10px 10px 10px;
font-size: 35px;
font-weight: bold;
font-family: Calibri;
}
#content {
background-color: #F5F5F5;
width: 100%;
height: 650px;
}
How about doing something like this
(JSfiddle example):
#header{
background-color: #1874CD;
width: 100%;
height: 70px;
z-index: 2;
position: relative;
}
#content{
position: absolute;
left: 0px;
top: 0px;
background-color: #F5F5F5;
width: 100%;
height: 100%;
padding-top: 70px;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box;
}

Resources