css main content height without scrollbar - html

I have tried a lot.
I do not get to 100% height without scrollbars:
/* =================== Global =================== */
*{
padding: 0px;
margin:0px;
}
html, body{
height: 100%;
background-color: #7a7a78;
font-size: 11px;
font-family: Verdana, sans-serif;
}
a{
color: #000;
text-decoration:none;
}
header{
max-width: 1000px;
margin: auto;
height: 75px;
background-color: #d0ccc9;
}
nav{
background-color: #964951;
height: 30px;
}
#nav{
max-width: 940px;
height: 30px;
margin: auto;
padding-left: 30px;
padding-right: 30px;
}
section{
margin: auto;
max-width: 970px;
background-color: #d0ccc9;
padding-left: 15px;
padding-right: 15px;
height: 30px;
}
main{
margin-left:auto;
margin-right:auto;
max-width: 970px;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 15px;
background-color: #d0ccc9;
min-height: 150px;
height: 100%;
}
footer{
padding-left: 15px;
padding-right: 15px;
background-color: #964951;
height: 75px;
color: #fff;
display: flex;
align-items: center; /* Vertikale Zentrierung */
justify-content: center; /* Horizontale Zentrierung */
}
footer a{
color: #fff;
text-decoration:none;
}
enter image description here
enter image description here
can someone tell me what I did wrong?
thank you
edit: sorry, I get the css code not inserted. always the same error although everything is correct

Without seeing the HTML code it's hard to judge, but your main element has height: 100%;. So if there are other elements outside the main element (which is very likely from your CSS), they will add to the height, which will make the overall height more than 100%, which again causes the scrollbars.
Addition after added link to picture of HTML code in comments:
It's as I wrote above: Above main there are header , nav and section, below it, there is the footer. According to the CSS you posted all this adds up to 100% PLUS 210px (210px is the sum of all other heights according to your CSS): There's the overflow that causes the scrollbar.
The solution: Apply height: calc( 100% - 210px) to the CSS rule for main (instead of the 100% height there)

Related

How to stop elements from resizing>

When I resize my webpage everything goes out of position. The text goes below the container and the image get too wide. How can I make it so everything stays in place when the image gets resized? I looked at a few solutions but none seemed to work for me. Any help would be appreciated!
body {
background-color: #ADD8E6;
padding: 10px;
margin: 0;
}
.hcontainer {
background-color: #FFFFE0;
height: 600px;
text-align: center
}
div h1, p {
padding-top: 10px;
padding-left: 10px;
padding-bottom: 5px;
margin: 0;
}
img {
margin: 0;
padding-top: 20px;
}
#mini {
font-size: 13px;
margin-top: 5px;
}
.imgcontainer {
background-color: pink;
}
.mcontainer {
background-color: #FFFFE0;
height: 600px;
margin-top: 20px;
padding-top: 30px;
}
li {
margin-top: 30px;
margin-left: auto;
margin-right: auto;
}
h3 {
text-align: center;
}
.list {
width: 50%;
margin-left: auto;
margin-right: auto;
}
h4 {
text-align: center;
padding-top: 20px;
Use percentages instead of px, this will make any elements a relative size when resizing the window.
Use percentages instead of Pixels, And be careful the width of all the components companied should be 100%.
So all the components width, the paddings, the margins even the borders counts! All companied should be 100% at the width.
Note: if you want to use borders is make sense more to use pixels so if you set the border for 1px for example you make the other components width companied 99%.
Another thing I recommend to you to learn and use Bootstrap to make responsive website to all platforms.

How to move image with css/html

I am trying to move an image. I Want it to be alligned with the title "Experience". Here is my code
html code
<header>
<h1>Experience</h1>
<div class="logo">
<img src="./img/exp.png">
</div>
</header>
and the css code
.logo{
width: 100px;
}
.logo img{
float: left;
margin-left: 0px 0px 0px 30px;
width: 150px;
height: 38px;
}
Just tweak the CSS a little:
.logo{
width: 100px;
display: inline-flex;
}
.logo img{
margin: auto 5px;
float: left;
width: 150px;
height: 38px;
}
Does this work?
This solution worked for me, but I have no idea for you as you didn't put your full code...
Try adding float:left to .logo and setting display: inline-block on your h1, like so:
*{
margin: 0px;
padding: 0px;
font-family: Arial, Helvetica, Sans-serif;
font-size: 34px
}
header{
background-image: url(../img/bar.png);
background-color: #00B9ED;
height: 75px;
border-bottom: 0px;
padding-left: auto;
padding-right: auto;
width: 100%;
}
.logo{
width: 100px;
float: left;
//display: inline-flex;
}
.logo img{
margin: auto 5px;
float: left;
width: 150px;
height: 38px;
}
h1 {
display: inline-block;
}
How about making margin-left: 0%; and margin-right. Depends where you want to move it.
You used shorthand for margin-left. We use shorthand for margin only. You did margin-left: top right bottom left instead. I don't think the program reads that correctly.

Display container on full page

EDIT: jsfiddle
I have set
html{
height: 100%;
}
And
body{
min-height: 108%;
}
I want to show the content to full height to the footer even if content is empty.
This is container
And this is content
You can fix this by adding height:100% in addition to the min-height:108% to you body element:
http://jsfiddle.net/C8UUt/1/
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
min-height: 108%;
height: 100%;
}
Update
To make the sidebar1 full height you can use a little trick:
http://jsfiddle.net/C8UUt/3/
.container {
width: 960px;
background: #FFF;
margin: 0 auto;
min-height: 100%;
position: relative; // added this to tell position:absolute that this is his parent
}
.sidebar1 {
float: left;
width: 180px;
background: #EADCAE;
padding-bottom: 10px;
display: inline-block;
height: 100%; // to make it 100% height
position: absolute; // added this so it will take `min-height` of parent into account
}
.content {
padding: 10px 0;
width: 780px;
display: inline-block;
/* float: left; */
height: inherit;
margin-left: 180px; // since position:absolute doesn't take part in the normal flow, we must account for that space manually
}
if your browser supports CSS3 use this:
.container {height:100vh;}

When browser is resided part of the header background is missing

The header in the pic is styled in 3 parts the top part contains a div with the width 100% and background color and inside the dive there is a div styled as a container which holds all elements at the top. This container has a width of 1000px and min-width of 960px and margin: 0 auto;
but when u re-size the browser and scroll with the scroll-er at the bottom the header appears as follows.
What am I doing wrong here for it to render this way?
CSS
#header {
height: 120px;
width: 100%;
margin-bottom: 15px;
}
#header .nav-content-holder {
width: 1000px;
min-width: 960px;
margin: 0 auto;
}
#header .header-menu-top {
height: 20px;
background-color: #d8d4cf;
color: #Color-Txt-black;
}
#header .header-menu-middle {
height: 70px;
background-color: #Color-FM-brown;
color: #Color-Txt-white;
}
#header .header-menu-bottom {
border-top: 1px solid #d3d3d3;
height: 28px;
background-color: #Color-FM-brown;
margin-bottom: 15px;
color: #Color-Txt-white;
}
HTML
Without code it is impossible to know what is going on but you need to try min-width: 1040px; on body.

CSS 100% height with header and footer

I am having difficulties achieving Css 100% so my website can look right in every web browser. I followed a tutorial I found HERE but no luck in getting it working. I have an example that contains a footer. This footer is also not in place. Also, I am trying to have the surrounding black frame cover my footer. Is there something I am doing wrong?
For better details please look at my
LIVE EXAMPLE
CSS
<style>
html,body {
padding: 0px;
margin: 0px;
background: #333333;
background-size: 100%;
line-height: 130%;
height: 100%
font-family: trebuchet, 'trebuchet ms', 'tahoma', sans-serif;
font-size: 90%;
color: #5e5e5e;
}
/****** COLORBLOCK: this is the orangey-yellow bar behind the wrapper i the background. ******/
#colorblock {
position: absolute;
top: 60px;
left: 0px;
background: #c69a55;
z-index: -1;
height: 65px;
width: 100%;
padding: 0px;
margin: 0px;
}
/****** WRAPPER: this is the light gray box that is the background for all of the content. DO NOT EDIT. ******/
#container {
z-index: 1;
width: 850px;
position: relative;
margin: 0 auto;
height:auto !important; /* real browsers */
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
}
#contentArea{
padding:1em 1em 5em;
min-height:700px;
width: 850px;
position:relative;
background: #f2f2f2;
border-right: 15px solid #000000;
border-left: 15px solid #000000;
position: relative;
}
/****** TOP BANNER: This is the banner with Greg's List logo and main navigation. Also includes the styles for the main navigation links. ******/
#header {
width: 100%;
height: 180px;
}
/****** FOOTER: This is the junk at the bottom of the page. Do NOT remove the clear div; it's what makes it stick to the bottom. ******/
#clear {
clear: both;
margin-bottom: 10px;
}
#addSpace{
padding-bottom:7px;
}
.bottomNav {
margin-right:auto;
margin-left:auto;
width:880px;
height: 200px;
background: #7a7a7a;
}
#footer{color:#FFF; position:absolute; bottom:0; width:100%; padding-bottom:10px; padding-top:10px;}
</style>
to set the footer in place you just need to reset width: 905px; in .bottomNav class
use ( width: calc ) property in css
for example.
u need header 100px and footer 100px with 100% content height
css
body, html{height:100%; margin:0px;}
.header{height:100px;}
.footer{height:100px;}
.content{height: 100%;
height: -webkit-calc(100% - 200px);
height: -moz-calc(100% - 200px);
height: calc(100% - 200px);
}
we set -200 bcoz header height 100px + footer height 100px so 100+100 = 200