Floats and paddings - equal height - html

I have a page with a container and two columns. My structure looks this
<div id="page">
<div id="left"></div>
<div id="right"></div>
</div>
Here is the CSS
#page {
min-height: 100%;
height: 100%;
width: 90%;
font-size: 100%;
margin: 0 auto 0 auto;
padding: 0;
font-size: 1em;
position: relative;
}
#left {
background-image: url("../images/layout/background.png");
width: 198px;
min-height: 100%;
float: left;
}
#right {
margin-left: 230px;
min-height: 100%;
background-color: #FFFFFF;
border: 1px solid red;
padding: 150px 20px 0px 20px;
text-align: justify;
}
At the moment with the previous code the #page element doesn't stretch to the bottom and neither does the #left. If I remove the paddings from #right, #page and #left are equal height with #right.
How do I solve this?

So there are a couple ways you could handle that. If you're looking to just have two columns with different backgrounds that both reach the bottom of their container you could use a background image that repeats vertically or a css3 gradient. I set up an example here:
http://jsfiddle.net/29wBn/1/
Notice the gradient background on the #page element
#page {
background: -moz-linear-gradient(left, #b2f8ff 0%, #b2f8ff 50%, #9effaf 50%, #9effaf 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#b2f8ff), color-stop(50%,#b2f8ff), color-stop(50%,#9effaf), color-stop(100%,#9effaf)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* IE10+ */
background: linear-gradient(to right, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b2f8ff', endColorstr='#9effaf',GradientType=1 ); /* IE6-9 */
overflow:hidden; /* make the container wrap the floated contents */
}
As a fall back the #page element gets assigned the left columns color and the right column receives it's own color.
Chris Coyer wrote a great article that shows several different ways.
http://css-tricks.com/fluid-width-equal-height-columns/

Related

How to make this section full height of the screen? Whatever we do it leaves white space on the bottom

We are trying to make the content full height of the screen but whatever we do it shows white space on the bottom of the screen. How can be it fixed?
section {
height: 100vh;
background-size: cover;
background: #FF512F;
/* fallback for old browsers */
background: -webkit-linear-gradient(to right, #FF512F, #DD2476);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #FF512F, #DD2476);
padding-top: 5%;
/* New code */
overflow: hidden;
padding-top: 80px;
margin-top: -100px;
height: 150%;
}
.emp-profile {
padding: 10%;
border-radius: 0.5rem;
background: #fff;
margin-top: 80px;
margin-bottom: 80px
}
<section *ngIf="user" (onlineUsers)="online($event)">
<div class="container">
<div class="emp-profile justify-content-center">
... ...
</div>
</div>
</section>
I can't use body tag because this is an angular separate component and starts with the section.
How can I make that section full height of the screen? We are using Bootstrap 4 with Angular 6
There is a negative margin on the section. That moves the entire section up 150px. Also don't define height twice in the CSS. Whatever the negative margin is, it must be added back to the height...
section {
height: calc(100vh + 80px);
background-size: cover;
background: #FF512F; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #FF512F, #DD2476);
background: linear-gradient(to right, #FF512F, #DD2476);
padding-top: 80px;
margin-top: -80px;
}
https://www.codeply.com/go/BdVBClITv0
added 100vh and removed margin and padding section
section {
height: 100vh;
background-size: cover;
background: #FF512F;
/* fallback for old browsers */
background: -webkit-linear-gradient(to right, #FF512F, #DD2476);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #FF512F, #DD2476);
/* New code */
overflow: hidden;
height: 100vh;
}
.emp-profile {
padding: 10%;
border-radius: 0.5rem;
background: #fff;
margin-top: 80px;
margin-bottom: 80px
}
body {
margin: 0;
padding: 0
}
<section *ngIf="user" (onlineUsers)="online($event)">
<div class="container">
<div class="emp-profile justify-content-center">
... ...
</div>
</div>
</section>

HTML: Div inside Div always bound to parents borders

I want to have a div inside a parent div which is not attached to borders of the parent.
Currently, I've following html code in the index.html:
<div id="high_prio_container">
<div class="overlay">
<div class="article_content">
<h1>
<strong><span class="text-primary">Some title</span></strong> text</p>
</div>
</div>
</div>
And here's the CSS code:
#high_prio_container{
background: url(bootstrap/img/c01.jpg);
background-size: cover;
background-position: center;
background-attachment: fixed;
background-repeat: no-repeat;
color: #cfcfcf;}
#high_prio_container .overlay{
background: -moz-linear-gradient(top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.73) 17%, rgba(0,0,0,0.66) 35%, rgba(0,0,0,0.55) 62%, rgba(0,0,0,0.4) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.8)), color-stop(17%,rgba(0,0,0,0.73)), color-stop(35%,rgba(0,0,0,0.66)), color-stop(62%,rgba(0,0,0,0.55)), color-stop(100%,rgba(0,0,0,0.4))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc000000', endColorstr='#66000000',GradientType=0 ); /* IE6-9 */
height: 750px;
background-attachment: fixed;}
.article_content{
margin-top: 30px;
padding: 100px;
margin-left: 5%;
position: relative;
padding: 5% 0 0;
z-index: 1000;
background-color: gray;
opacity: 0.5;}
The problem is now that no matter what I do, I can't move the child div (.article_content) away from the borders of the parent container. If I use margin, I get a black space (size of margin) between the child and parent div.
I hope that this is somehow understandable. I made this pic to illustrate the problem:
It is called margin-collapsing. There are many ways you can solve it.
One way is use following css:
#high_prio_container .overlay{
padding: 0.1px;
}
Working Demo
Another way it give position: absolute; to .article_content
Or
display: inline-block; to .article_content
What would work is working with padding in the parent container (or even the child container if you have a transparent background). So you could use:
.overlay {
padding-top: 30px;
}

Sticky Footer on mobile devices overlapping

I have a footer as follows:
<div class="footer-content">
<div class="footer-left">
<p>The content of this site is owned by MR X, or their respective copyrights holders.</p>
<p>No part of this site may be copied or reproduced without permission. Per request, non commercial rights to use any content can be released.</p>
<p>Thank you for viewing the site!</p>
</div>
<div class="footer-right">
Designed and Created by Jango Puppies
</div>
</div>
html body Footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjM4JSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjY2JSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, transparent 1%, black 38%, black 66%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%, transparent), color-stop(38%, black), color-stop(66%, black));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, transparent 1%, black 38%, black 66%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, transparent 1%, black 38%, black 66%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, transparent 1%, black 38%, black 66%);
/* IE10+ */
background: linear-gradient(to bottom, transparent 1%, black 38%, black 66%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#000000',GradientType=0 );
/* IE6-8 */
margin-top: 2rem;
}
html body Footer .footer-content {
padding-top: 1.5rem;
max-width: 102.4rem;
width: 100%;
margin: 0 auto;
height: 100%;
}
html body Footer .footer-content .footer-left {
width: calc(100% - 20rem);
float: left;
}
html body Footer .footer-content .footer-left p {
font-size: 1.5rem;
}
html body Footer .footer-content .footer-right {
float: right;
width: 12rem;
margin-right: 2rem;
}
html body Footer .footer-content .footer-right a {
font-size: 1.5rem;
}
When I view this footer on the browser, it looks great. It sticks to the bottom if there is not enough content and it shows up only after I scroll to the bottom if there is a lot of content (I intend it like this) and there are no issues. When I view this footer on my android cellphone the footer sticks to the bottom but it overlaps the text. Live demo at [claymation.azularis.com][1].
How can I prevent this on mobile devices? Should I be using a different kind of sticky footer?

Why does background-gradient not scale?

My CSS gradient in the background does not scale, what can I do?
I plan to do a HTML layout in percentage, but the body gradient is too short.
example: http://jsfiddle.net/snGVt/
<div class="wrapper">
<div class="box round"><img src="http://goo.gl/wv4zi" /></div>
<div class="box round"><img src="http://goo.gl/wv4zi" /></div>
</div>
html{
height: 100%;
width:100%;
}
body {
width:100%;
background: #0e89b6; /* Old browsers */
background: -moz-linear-gradient(top, #0e89b6 0%, #00142c 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0e89b6), color-stop(100%,#00142c)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0e89b6 0%,#00142c 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0e89b6 0%,#00142c 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0e89b6 0%,#00142c 100%); /* IE10+ */
background: linear-gradient(to bottom, #0e89b6 0%,#00142c 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0e89b6', endColorstr='#00142c',GradientType=0 ); /* IE6-9 */
}
.wrapper {
width: 60%;
margin-left: auto;
margin-right: auto;
}
.box{
width: 100%;
margin-top: 10px;
padding: 25px;
background-color: #fff;
}
.box > img{
width: 100%;
}
Try changing the html width and height styles to "min-height: 100%" and min-width: 100%"
html{
min-height: 100%;
min-width:100%;
}
Use background-size.
CSS3 gradients can be considered as functions that generate a fixed-sized image, so they still need to be controlled with the size property.
In IE9 there was some margin around the edge of the gradient. You should set your body and html to have no margin. Is that what you were having a problem with?
html,body {
margin: 0;
}
Note this wasn't an issue for me in other browsers.

Dynamic content height with min-height

I am writing a little browsergame to improve my webskills, but I'm stuck within a layout problem. My gamepage consists of a header, content and a footer with two spacers with a backgroundimage between. The content-div should be stretched vertical, so that the whole space of the view is used. If the content is taller then the browser, it should be stretched further with scrollbars. Its important that the heights are correct, because i use a gradient fill for the background and this shouldn't repeat at some point. I thought i can achieve this with height:auto for content with big size and with min-height:100% for content with small size. But this doesn't work. I read several forum-posts, but nothing is working. Could you help me please? Wheres my error in reasoning?
HTML:
(The br's are used to oversize the page)
<html>
<head>
<link rel="stylesheet" type="text/css" href="mycss.css">
</head>
<body>
<div class="center">
<div class="header">
Header
</div>
<div class="spacer"></div>
<div class="main">
Content
<!--<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>-->
</div>
<div class="spacer"></div>
<div class="footer">
Footer
</div>
</div>
</body>
</html>
CSS:
html,body {
margin:0px;
padding:0px;
height: auto;
min-height: 100%;
}
body {
background: rgb(122,188,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(122,188,255,1) 0%, rgba(96,171,248,1) 44%, rgba(64,150,238,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(122,188,255,1)), color-stop(44%,rgba(96,171,248,1)), color-stop(100%,rgba(64,150,238,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(122,188,255,1) 0%,rgba(96,171,248,1) 44%,rgba(64,150,238,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(122,188,255,1) 0%,rgba(96,171,248,1) 44%,rgba(64,150,238,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(122,188,255,1) 0%,rgba(96,171,248,1) 44%,rgba(64,150,238,1) 100%); /* IE10+ */
background: linear-gradient(top, rgba(122,188,255,1) 0%,rgba(96,171,248,1) 44%,rgba(64,150,238,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7abcff', endColorstr='#4096ee',GradientType=0 ); /* IE6-9 */
}
.center {
height: auto;
min-height: 100%;
width:1024px;
margin-left:auto;
margin-right:auto;
text-align:left;
box-shadow: 0px 0px 20px 0px #000;
background: rgb(181,189,200); /* Old browsers */
background: -moz-linear-gradient(top, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(117,117,117,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,1)), color-stop(36%,rgba(130,140,149,1)), color-stop(100%,rgba(117,117,117,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(117,117,117,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(117,117,117,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(117,117,117,1) 100%); /* IE10+ */
background: linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(117,117,117,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#757575',GradientType=0 ); /* IE6-9 */
}
.spacer{
min-height:16px;
background-image: url(Absperrband.png);
background-repeat: repeat;
-webkit-box-shadow: 0px 0px 5px 0px #000;
box-shadow: 0px 0px 5px 0px #000;
}
.header {
padding : 8px;
height:70px;
}
.main{
min-height: 100%;
padding : 12px;
}
.footer{
padding : 12px;
}
Sounds like you're looking for a 'sticky footer' effect.
http://www.cssstickyfooter.com/
html, body should be height:100% and your main div (.center) should have the min-height:100%; height:auto
DEMO
add display:inline-block; to the body and .center
and see the result
add display:inline-block;text-align:center; to the body
and display:inline-block;text-align:left; to the .center
Hope it can fix my answer