Responsive Scrolling div height - html

I have a footer that is fixed. I have a header that is relative. In between these containers there is the content which is set to overflow-y:auto. Meaning the scrollbar should show for only in this div container. I have a container around this content div. The height for this div is set to pixels because when percentage is used, it automatically goes to 100% and the scrollbar is not visible. It looks perfect on 100% without changing the height of the screen. However, if the user were to change the height of the screen - the user can not see all of the content in the div because the fixed footer is now covering that. When the user zooms out, there is a white space in between the footer and the div. I would like it so that when the user zooms out there isn't a white space and when the user changes the height of the screen, the user can view all of the content.
HTML
<div class="top-container">
</div>
<div class="container">
<ul>
<li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
</ul>
</div>
<footer>
</footer>
CSS
.top-container {
position: relative;
z-index: 6;
background: #fff;
padding: 40px 40px 0;
bottom: 0;
width: 100%
}
.container {
padding: 10px 0;
margin: 0 .6%;
}
ul {
padding-top: 2px;
height: 437px;
overflow-y: auto;
overflox-x: hidden;
}
footer{
background: #fff;
padding: 20px 50px;
overflow: hidden;
position: fixed;
z-index: 5;
left: 0;
bottom: 0;
width: 100%;
}
JSFIddle This JSfiddle does not accurately show my issue. The scrollbar should only be displayed in the content and not the header. Which is what it is now.
Thanks

.top-container {
position: relative;
z-index: 6;
background: #fff;
padding: 40px 40px 0;
bottom: 0;
width: 100%;
max-height: 60px;
background: green;
}
.container {
padding: 10px 0;
margin: 0 .6%;
overflow-y: scroll;
height: calc(100vh - 100px);
background: blue;
}
ul {
padding-top: 2px;
height: 437px;
overflow-y: auto;
overflox-x: hidden;
}
footer{
background: #fff;
padding: 20px 50px;
overflow: hidden;
position: fixed;
z-index: 5;
left: 0;
bottom: 0;
width: 100%;
}
body{
max-height: 90vh;
}
footer{
background: red;
max-height: 40px;
}
<div class="top-container">
</div>
<div class="container">
<ul>
<li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
</ul>
</div>
<footer>
</footer>
Here is the updated jsFiddle

.top-container {
position: relative;
z-index: 6;
background: #fff;
padding: 40px 40px 0;
bottom: 0;
width: 100%
}
.container {
padding: 10px 0;
margin: 0 .6%;
}
ul {
padding-top: 2px;
//height: 437px;
overflow-y: auto;
overflox-x: hidden;
}
footer{
background: #fff;
padding: 20px 50px;
overflow: hidden;
z-index: 5;
width: 100%;
}
Is this what you want?

Related

Display full image in a box

I have an input that when selecting an image it fills all this box ...
In order to completely fill this box I used 100% height and width ... in fact the image occupies the entire box, but not all of its details are visible.
Is there any way to get the image to occupy 100% but in which all your content is visible?
My problem:
Original Image
Picture inside the box (What I have)
As you can see, the image occupies the whole box (it's correct) but the problem is that the full image doesn't appear :(
Any solution?
Thanks!
My code and test
HTML
<div class="drop">
<div class="cont" *ngIf="urls.length === 0">
<div class="browse" >
Upload files
</div>
</div>
<div *ngIf="urls.length > 0">
<img [src]="urls[0]">
</div>
<input type="file" id="files" multiple (change)="detectFiles($event)" accept="image/*">
</div>
css
.drop {
margin-left: 32px;
width: 928px;
height: 696px;
border-radius: 15px;
overflow: hidden;
text-align: center;
background: white;
/* margin: auto; */
position: relative;
top: 0;
left: 0;
bottom: 0;
right: 0;
/*&:hover
cursor: pointer
background: #f5f5f5*/;
}
.drop .cont {
width: 500px;
height: 170px;
color: #8E99A5;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.drop .cont i {
font-size: 400%;
color: #8E99A5;
position: relative;
}
.drop .cont .browse {
margin: 10px 25%;
padding: 8px 16px;
border-radius: 16px;
background: #ECF2F9;
text-align: center;
font: Bold 13px/20px Noto Sans;
letter-spacing: 0;
color: #4D4F5C;
}
.drop input {
width: 928px;
height: 650px;
cursor: pointer;
background: red;
opacity: 0;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#list {
width: 100%;
text-align: left;
position: absolute;
left: 0;
top: 0;
}
#list .thumb {
height: 100%;
margin: 10px 5px 0 0;
}
img {
width: 100% !important;
height: 100% !important;
}
It's because your giving a fixed height to the parent container, what you have to add is this:
.drop{
box-sizing: border-box;
}
.drop>img{
width: 100%;
height: auto;
}
It's because of this line:
.drop {
overflow: hidden;
}
If you change it to overflow: visible/scroll it will work.
If you don't want the image to scroll you could edit the css like this:
img {
width: auto;
height: auto;
max-height: 100%;
max-width: 100%;
}
I updated. Try this.
img {
height: 100% !important;
}
.abc {
width: 100% !important;
height: 100% !important;
}
<div class="abc" *ngIf="urls.length > 0">
<img [src]="urls[0]">
</div>

Keeping the footer on the bottom of the page?

I know this is a common issue but I just can't work this out. No matter how many combinations of settings I try, the footer won't stay on the bottom of the page. It will just sit under whatever else is above it.
body {
margin: 0;
background-color: #ACFAB7;
}
# container {
margin: 0 auto;
padding: 40px;
}
#header {
z-index: 0;
height: 78px;
background-color: #2ecc71;
}
#footer {
z-index: 2;
height: 40px;
width: 100%;
padding: 0px;
position: relative;
background-color: #2ecc71;
/*display required to center text*/
display: table;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#image {
z-index: 1;
margin: 20px auto;
padding: 50px;
}
/*Centers text within the header*/
span {
display: table-cell;
vertical-align: middle;
}
You have a lot of problems. This solution is for:
Fixing your footer at the end of the page.
Centering the contents (both vertically and horizontally).
Fixes
Get rid of display: table.
Get rid of width: 100%.
Change relative to fixed.
#footer {
z-index: 2;
line-height: 40px;
padding: 0px;
position: fixed;
background-color: #2ecc71;
text-align: center;
left: 0; right: 0;
bottom: 0;
}
<div id="footer">Copyrights.</div>
position: fixed; and bottom: 0; should do the trick. Add width and height as neccessary.
.footer {
position: fixed;
bottom: 0;
width: 100%;
height: 30px;
background-color: aquamarine;
}
<div style="background-color: lightgrey;height: 800px">
Page content
</div>
<div class="footer">
this is the footer
</div>
You can use position: fixed; bottom: 0;
#footer {
z-index: 2;
height: 40px;
width: 100%;
padding: 0px;
background-color: #2ecc71;
text-align: center;
margin-left: auto;
margin-right: auto;
position:fixed;
bottom:0;
left: 0;
}
<div>
<footer id="footer">Footer</footer>
</div>

Two divs scrolling independently

I need help to make these two <div>'s (#side-nav and #content-wrapper) to scroll independently,
HTML:
<div id="wrapper">
<div id="top-nav">
Top nav
</div>
<div id="side-nav">
<ul>
<li>Thing</li>
<li>Thing</li>
</ul>
</div>
<div id="content-wrapper">
<!-- Ton of conent here -->
</div>
</div>
CSS:
#wrapper {
width: 100%;
background-color: #fff;
}
#top-nav {
position: fixed;
top: 0;
height: 60px;
width: 100%;
background-color: green;
}
#side-nav {
position: fixed;
width: 250px;
height:100vh;
overflow-y: scroll;
background-color: red;
}
#content-wrapper {
margin: 60px 0 0 250px;
padding: 0 30px;
overflow-y: scroll;
background-color: blue;
}
now if I scroll the #side-nav to the end or top, #content-wrapper will scroll too. #side-nav has to stay full-page height and fixed even if there is not that many <li>'s.
I've quickly made pen here:
http://codepen.io/blizqery/pen/QbZzRN
Thanks!
Check this: http://codepen.io/anon/pen/xGyMjM
You need to set height to content-wrapper, and also set the left, right & top.
#side-nav {
position: fixed;
width: 250px;
height:100vh;
left: 0;
right: 0;
overflow-y: scroll;
background-color: red;
top: 60px;
}
#content-wrapper {
margin: 60px 0 0 250px;
padding: 0 30px;
overflow-y: scroll;
position: fixed;
left: 0;
top: 0;
height:100vh;
background-color: blue;
}
I believe this works for your issue
body{
margin:0px;
}
#top-nav {
position: fixed;
top: 0;
height: 10vh;
width: 100%;
background-color: green;
}
#wrapper {
width: 100%;
background-color: #fff;
}
#side-nav {
float:left;
width: 250px;
height: 90vh;
overflow-y: scroll;
background-color: red;
}
#content-wrapper {
margin: 10vh 0 0 250px;
padding: 0 30px;
overflow-y: scroll;
background-color: blue;
height:90vh;
}

CSS background positioning different in safari and firefox

I have design a website homepage made of 4 sections. Top, mid1, mid2 and bottom. Each section has a min height of 100% of the web browser. The top section has a transparent background colour with a image/video background.
When the user scrolls down the #videosection should stay behind each section, instead in Safari it does not keep the video section behind the other sections and firefox does not show the video section. Everything is fine using chrome.
HTML:
<body>
<div id="videosection"><video src=""id="bg-video" muted autoplay loop ></video></div>
<div class="top-section">
</div>
<div class="mid1-section">
<div id="center-box">
<section></section>
</div>
<div class="mid2-section">
<div class="textbanner"><h3>Design</h3></div>
<div class="devices box"><img src=""></div>
</div>
<div class="bottom-section">
<div id="registerform"></div>
</div>
</body>
Heres the CSS:
html, body{
background-color: #ECF0F1;
min-height:100%;
margin: 0;
padding: 0;
}
#videosection {
position: fixed;
top: 0%;
left: 0%;
width: 100%;
height: 100%
z-index: 1;
}
videosection video {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 60%;
min-height: 50%; }
.top-section{
background: -webkit-linear-gradient(rgba(255,119,85,0.89), rgba(255,92,106,0.82) ); /* For Safari / background: -o-linear-gradient(rgba(255,119,85,0.89), rgba(255,92,106,0.82)); / For Opera 11.1 to 12.0 / background: -moz-linear-gradient(rgba(255,119,85,0.89), rgba(255,92,106,0.82)); / For Firefox 3.6 to 15 / background: linear-gradient(rgba(255,119,85,0.89), rgba(255,92,106,0.82)); / Standard syntax */ background-repeat: repeat;
position: relative;
top: 0;
left: 0;
min-width: 100%;
min-height: 100%;
z-index: 15;}
#center-column {
position: relative;
margin: 0;
margin-top: 10%;
margin-bottom: 5em;
padding: 0;
}
.mid1-section{
min-height:100%;
width: 100%;
background-color: #ff5b68;
margin: 0;
padding: 0;
text-align: center;
position: relative;
z-index: 15;}
#center-box {
overflow: hidden;
float: none;
text-align: center;
width: 60%;
margin-left: auto;
margin-right: auto;
margin-top: 0;
margin-bottom: 0;}
.mid2-section{
min-height:100%;
width: 100%;
background-color: #3499dc;
margin: 0;
padding: 0;
text-align: center;
position: relative;
z-index: 15;}
.textbanner {
overflow: hidden;
float: none;
height: 20%;
width: 100%;
margin: 0;
padding-top: 3em;
}
section {
overflow: hidden;
text-align: center;
margin: 0;
float: left;
background-color: #ff5b68;
height: 10.5em;
width: 40%;
padding-left: 5%;
padding-right: 5%;
padding-top: 5em;
padding-bottom: 0;
}
.bottom-section{
min-height:100%;
width: 100%;
background-color: #1ABC9C;
margin: 0;
padding: 0;
text-align: center;
position: relative;
z-index: 15;}
#registerform {
background-color: #16A085;
border: 1px solid #16A085;
border-radius: 5px;
width: 420px;
margin-top: 0;
margin-left: auto;
margin-right: auto;
padding: 5%;
}
First of, it's better to put the video for last, this will improve the loading of the page.
For making the video stay behind the rest, use z-index: -1; in #videosection.

Absolutely positioned div containing a child div with overflow hidden which contains 2 divs, one fixed height and one scrolling

A web app has the following structure but the scroll goes off the page. Any ideas what is going wrong?
http://jsfiddle.net/kYEES/
HTML
<div class="wrapper">
<div class="container">
<div class="fixed-height">
<p>Fixed height div</p>
</div>
<div class="scrolling-height">
<p>Scrolling div</p>
</div>
</div>
</div>
CSS
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.wrapper {
position: absolute;
height: 100%;
width: 100%;
}
.container {
background: lightgray;
height: 100%;
overflow: hidden;
padding: 10px;
position: relative;
}
.fixed-height {
background-color: yellow;
height: 40px;
padding: 5px 10px;
}
.scrolling-height {
background-color: green;
bottom: 0;
height: 100%;
overflow-y: scroll;
margin-bottom: 20px;
padding: 5px 10px;
position: absolute;
top: 40px;
}
Something like this: http://jsfiddle.net/DhWm5/3/
I gave your container a position: relative and your scrollable div an absolute position:
.container {
background: lightgray;
height: 100%;
padding: 10px;
position:relative;
}
.scrolling-height {
background-color: green;
margin-bottom: 50px;
overflow-y: scroll;
padding: 5px 10px;
position:absolute;
top: 50px; bottom: 0;
}
The top: 50px is to allow for the fixed height div and its padding;