I have 2 scrolling divs (outlined in red) that will not scroll to the their respective bottoms. I can't seem to seem to figure out what to tweak to fix it.
The thick outlined box is a simulated browser window.
http://jsfiddle.net/jsk55rfb/4/
HTML
<div class="container">
<div class="header"></div>
<div class="sidebar"></div>
<div class="main">
<div class="detail-container">
<div class="top-info"></div>
<div class="items-container">
<div class="item blue"></div>
<div class="item orange"></div>
<div class="item blue"></div>
<div class="item orange"></div>
</div>
</div>
<div class="main-container">
<div class="main-header"></div>
<div class="main-content">
<div class="item grey"></div>
<div class="item purple"></div>
<div class="item grey"></div>
<div class="item purple"></div>
<div class="item grey"></div>
<div class="item purple"></div>
<div class="item grey"></div>
<div class="item purple"></div>
</div>
</div>
</div>
</div>
CSS
.container {
height: 500px;
width: 500px;
border: solid 3px black;
overflow: hidden;
}
.header {
height: 25px;
background-color: #333;
right: 0;
left: 0;
}
.sidebar {
position: fixed;
top: 0;
bottom: 0;
width: 75px;
margin-top: 35px;
border: solid 1px grey;
}
.main {
height: 100%;
padding-left: 75px;
}
.main-container {
width: 65%;
height: 100%;
}
.main-content {
height: 100%;
overflow-y: scroll;
border: solid 1px red;
}
.main-header {
height: 20px;
border: 1px solid black;
}
.detail-container {
float: right;
width: 35%;
height: 100%;
border: solid 1px grey;
}
.top-info {
padding: 75px 0;
}
.items-container {
height: 100%;
overflow-y: scroll;
border: solid 1px red;
}
.item {
padding: 100px 0;
}
.blue { background-color: blue; }
.orange { background-color: orange; }
.grey { background-color: grey; }
.purple { background-color: purple; }
.content {
width: 65%;
height: 100%;
}
You have a fixed height for the container and overflow set to hidden. Since the divs exceed that height, the overflow can't be seen.
Try this:
.container {
height: 500px;
width: 500px;
border: solid 3px black;
overflow: scroll;
}
.header {
height: 25px;
background-color: #333;
right: 0;
left: 0;
}
.sidebar {
position: fixed;
top: 0;
bottom: 0;
width: 75px;
margin-top: 35px;
border: solid 1px grey;
}
.main {
height: 100%;
padding-left: 75px;
}
.main-container {
width: 65%;
height: 100%;
}
.main-content {
height: 100%;
overflow-y: scroll;
border: solid 1px red;
}
.main-header {
height: 20px;
border: 1px solid black;
}
.detail-container {
float: right;
width: 35%;
height: 100%;
border: solid 1px grey;
}
.top-info {
padding: 75px 0;
}
.items-container {
height: 100%;
overflow-y: scroll;
border: solid 1px red;
}
.item {
padding: 100px 0;
}
.blue { background-color: blue; }
.orange { background-color: orange; }
.grey { background-color: grey; }
.purple { background-color: purple; }
.content {
width: 65%;
height: 100%;
}
<div class="container">
<div class="header"></div>
<div class="sidebar"></div>
<div class="main">
<div class="detail-container">
<div class="top-info"></div>
<div class="items-container">
<div class="item blue"></div>
<div class="item orange"></div>
<div class="item blue"></div>
<div class="item orange"></div>
</div>
</div>
<div class="main-container">
<div class="main-header"></div>
<div class="main-content">
<div class="item grey"></div>
<div class="item purple"></div>
<div class="item grey"></div>
<div class="item purple"></div>
<div class="item grey"></div>
<div class="item purple"></div>
<div class="item grey"></div>
<div class="item purple"></div>
</div>
</div>
</div>
</div>
I could solve this with some javascript. This should addapt to any content size of your other blocks as long as the markup structure doesn't change.
Good luck!
$(function(){
//creating vars based on jquery objects
$itemsContainer = $('.items-container');
$mainContent = $('.main-content');
$container = $('.container');
$header = $('.header');
$mainHeader = $('.main-header');
//calculating heights
var containerH = $container.height();
var headerH = $header.height();
var mainHeaderH = $mainHeader.height();
//assigning new height to main-content class
$mainContent.css("height", (containerH - headerH - mainHeaderH) + "px");
//similar operation for items-container
//creating vars based on jquery objects
$topInfo = $('.top-info');
//calculating heights
var topInforH = $topInfo.outerHeight(); //since in your example top-info has no content only padding, you will need to use the method outerHeight instead of height
//assigning new height to main-content class
$itemsContainer.css("height", (containerH - headerH - topInforH) + "px"); });
By the way, I updated your jsfiddle with my solution, so you can test it.
When you use a height of 100% it sets it to the full height regardless of other sibling elements. So they are at 100% of the parent element but then the headers are pushing them down. You will have to use fixed heights on all elements. Or set one to 20% and other to 80% etc.
.main-content { width: 452px; }
.items-container {width: 352px; }
Related
I am trying to use the stick position with my header part. on scroll it works with couple of side move. then the header hides. it should be always in the top for my requirement. i have give z-index as well in higher value. any one help me to understand the issue.
HTML:
<div class="wrapper">
<div class="navi">Navigation</div>
<header>Header goes here</header>
<div class="container">
<div class="child1">Chile-1</div>
<div class="child2">Chile-2</div>
<div class="child3">Chile-3</div>
<div class="child4">Chile-4</div>
<div class="child4">Chile-5</div>
<div class="child4">Chile-6</div>
<div class="child4">Chile-7</div>
</div>
</div>
css:
html,
body {
height: 100%;
padding: 0;
margin: 0;
}
.wrapper {
height: 100%;
position: relative;
}
.container {
border: 2px solid blue;
height: 100%;
}
.navi {
border: 2rem solid lightpink;
}
header {
background-color: gray;
padding: 1rem;
top: 0;
left: 0;
right: 0;
position: sticky;
z-index: 100;
}
.container > div {
height: 50%;
border: 1px solid red;
}
.child1 {
background-color: brown;
}
.child2 {
background-color: yellow;
}
.child3 {
background-color: lightblue;
}
.child4 {
background-color: greenyellow;
}
Live demno
when adding 100% height to .wrapper and .container, the height get computed as below picture (838px in my case).. and when scroll crosses 838px, the header looses the sticky property.. when you set to auto, height will be computed automatically (adding all the divs' height) and it works expected..
height as 100%
height as auto
html,
body {
padding: 0;
margin: 0;
}
.wrapper {
position: relative;
}
.navi {
border: 2rem solid lightpink;
}
header {
top: 0;
padding: 1rem;
z-index: 100;
position: sticky;
background-color: gray;
}
.container>div {
padding: 30px;
position: relative;
z-index: 0;
}
.child1 {
background-color: brown;
}
.child2 {
background-color: yellow;
}
.child3 {
background-color: lightblue;
}
.child4 {
background-color: greenyellow;
}
<div class="wrapper">
<div class="navi">Navigation</div>
<header>Header goes here</header>
<div class="container">
<div class="child1">Chile-1</div>
<div class="child2">Chile-2</div>
<div class="child3">Chile-3</div>
<div class="child4">Chile-4</div>
<div class="child4">Chile-5</div>
<div class="child4">Chile-6</div>
<div class="child4">Chile-7</div>
<div class="child4">Chile-7</div>
<div class="child4">Chile-7</div>
<div class="child4">Chile-7</div>
<div class="child4">Chile-7</div>
<div class="child4">Chile-7</div>
<div class="child4">Chile-7</div>
</div>
</div>
I'm building a customised horizontal carousel, where in I want to display some items which are vertically scroll-able.
Code I've tried so far:
html
<div class="carousel">
<div class="c-item">Item-1</div>
<!-- to be displayed vertically -->
<div class="abs">
<div class="a-item">Abs Item-1.1</div>
<div class="a-item">Abs Item-1.2</div>
<div class="a-item">Abs Item-1.3</div>
</div>
<div class="c-item margin">Item-2</div>
<!-- to be displayed vertically -->
<div class="abs">
<div class="a-item">Abs Item-2.1</div>
<div class="a-item">Abs Item-2.2</div>
<div class="a-item">Abs Item-2.3</div>
</div>
</div>
<div class="other">
Other div
</div>
css
.carousel{
color: #FFF;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
position: initial;
.c-item{
display: inline-block;
width: 35%;
background: #000;
height: 100px;
&.margin{
//margin-left: 35%;
}
}
.abs{
background: #444;
display: inline-block;
vertical-align: top;
width: 35%;
max-height: 180px;
overflow-y: auto;
.a-item{
height: 100px;
border: 1px solid #000;
}
}
}
.other{
background: yellow;
}
Result:
(codepen)
The problem here is: I want the other div to start just below the item-1; meaning that the vertically scrolled div should be overlapping the other div and the carousel height should be fixed at 100px. I tried using position: absolute for the .abs div but then that div doesn't move on scrolling the carousel.
Desired output will look like this:
A flexbox solution
Each item is 33.33% wide and 100px high. The items inside .multiple are also 100px high.
.multiple has position: relative and overflow-y: auto. The items inside have position: absolute.
Hint: Container -> position: relative, items inside -> position: absolute. That's how it works.
top: (100 * n)px for each <div> inside .item.multiple. n is the index of the <div> inside .item.multiple, starting with 0.
The HTML structure has been changed
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.carousel {
display: flex;
width: 100vw;
overflow-x: auto;
color: white;
}
.carousel>.item {
flex: 1 0 33.33%;
//margin-right: 5px;
}
.carousel>.item:nth-child(odd) {
background: black;
}
.carousel>.item:nth-child(even) {
background: darkgrey;
}
.carousel>.item,
.carousel>.item.multiple>div {
height: 100px;
}
.carousel>.item.multiple {
position: relative;
overflow-y: auto;
}
.carousel>.item.multiple>div {
position: absolute;
width: 100%;
}
.carousel>.item.multiple>div:nth-child(2) {
top: 100px;
}
.carousel>.item.multiple>div:nth-child(3) {
top: 200px;
}
/* And so on ...
.carousel>.item.multiple>div:nth-child(...) {}
*/
<div class="carousel">
<div class="item">
<div>Item-1</div>
</div>
<div class="item multiple">
<div>Item-1.1</div>
<div>Item-1.2</div>
<div>Item-1.3</div>
</div>
<div class="item">
<div>Item-2</div>
</div>
<div class="item multiple">
<div>Item-2.1</div>
<div>Item-2.2</div>
<div>Item-2.3</div>
</div>
</div>
<div class="other">
Other div
</div>
Your desired result mean making the child overlap the parent, and i don't think that's possible. BUT you can "hack" this by wrapping the .carousel with another div (.demo it this general example), so the results will be something like this:
.demo {overflow: visible; height: 100px;}
.carousel {
color: #FFF;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
position: initial;
}
.carousel .c-item {
display: inline-block;
width: 35%;
background: #000;
height: 100px;
}
.carousel .abs {
background: #444;
display: inline-block;
vertical-align: top;
width: 35%;
max-height: 180px;
overflow-y: auto;
}
.carousel .abs .a-item {
height: 100px;
border: 1px solid #000;
}
.other {
background: yellow;
height: 200px;
}
<div class="demo">
<div class="carousel">
<div class="c-item">Item-1</div>
<div class="abs">
<div class="a-item">Abs Item-1.1</div>
<div class="a-item">Abs Item-1.2</div>
<div class="a-item">Abs Item-1.3</div>
</div>
<div class="c-item margin">Item-2</div>
<div class="abs">
<div class="a-item">Abs Item-2.1</div>
<div class="a-item">Abs Item-2.2</div>
<div class="a-item">Abs Item-2.3</div>
</div>
</div>
</div>
<div class="other">
Other div
</div>
As you can see from the snippet the scroll-x doesn't show - yet it exist. You can click one of the .carousel item and scroll them right and left.
Since it's not obvious that the .carousel is scrolling, you can add extra buttons to scroll it:
.demo {overflow: visible; height: 100px;z-index: 3;}
.carousel {
color: #FFF;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
position: initial;
}
.carousel .c-item {
display: inline-block;
width: 35%;
background: #000;
height: 100px;
}
.carousel .abs {
background: #444;
display: inline-block;
vertical-align: top;
width: 35%;
max-height: 180px;
overflow-y: auto;
}
.carousel .abs .a-item {
height: 100px;
border: 1px solid #000;
}
.other {
background: yellow;
height: 200px;
}
<div class="demo">
<button onclick="document.querySelectorAll('.carousel')[0].scrollLeft += 20;" style="position: fixed; top: 50%; right: 0;">L</button>
<button onclick="document.querySelectorAll('.carousel')[0].scrollLeft -= 20;" style="position: fixed; top: 50%; left: 0;">R</button>
<div class="carousel">
<div class="c-item">Item-1</div>
<div class="abs">
<div class="a-item">Abs Item-1.1</div>
<div class="a-item">Abs Item-1.2</div>
<div class="a-item">Abs Item-1.3</div>
</div>
<div class="c-item margin">Item-2</div>
<div class="abs">
<div class="a-item">Abs Item-2.1</div>
<div class="a-item">Abs Item-2.2</div>
<div class="a-item">Abs Item-2.3</div>
</div>
</div>
</div>
<div class="other">
Other div
</div>
Hope that helps!
You have to play with position check snippet.
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.carousel {
display: flex;
width: 100vw;
overflow-x: auto;
color: white;
}
.carousel>.item {
flex: 1 0 33.33%;
//margin-right: 5px;
}
.carousel>.item:nth-child(odd) {
background: black;
}
.carousel>.item:nth-child(even) {
background: darkgrey;
}
.carousel>.item,
.carousel>.item.multiple>div {
height: 100px;
}
.carousel>.item.multiple {
position: relative;
overflow-y: auto;
height: 200px;
}
.carousel>.item.multiple>div {
position: absolute;
width: 100%;
}
.carousel>.item.multiple>div:nth-child(2) {
top: 100px;
}
.carousel>.item.multiple>div:nth-child(3) {
top: 200px;
}
.other {
position: absolute;
z-index: -1;
top: 100px;
width: 100%;
background: green;
height: 117px;
}
/* And so on ...
.carousel>.item.multiple>div:nth-child(...) {}
*/
<div class="carousel">
<div class="item">
<div>Item-1</div>
</div>
<div class="item multiple">
<div>Item-1.1</div>
<div>Item-1.2</div>
<div>Item-1.3</div>
</div>
<div class="item">
<div>Item-2</div>
</div>
<div class="item multiple">
<div>Item-2.1</div>
<div>Item-2.2</div>
<div>Item-2.3</div>
</div>
</div>
<div class="other">
Other div
</div>
When I scroll on screen, everything is good.
When I click on my button, there is a overlay show up.
However, I can still scroll the div under my overlay, what i want is only to scroll my overlay.
$('#addCustomerBtn').on('click', function() {
// window.location.href = "http://dev.rabbijet.com/crm/create.html";
var modal = document.getElementById('myModal');
modal.style.display = "block";
})
body {
overflow: auto;
}
.black {
height: 200px;
width: 800px;
background-color: black;
}
.gray {
height: 200px;
width: 800px;
background-color: gray;
}
.green {
height: 700px;
background-color: green;
}
.yellow {
height: 700px;
background-color: yellow;
}
#addCustomerBtn {
font-size: 14px;
width: 120px;
border: 1px solid #20ACB3;
background-color: #20ACB3;
}
#myModal {
display: none;
position: fixed;
/* Stay in place */
z-index: 999;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
background-color: rgba(0, 0, 0, 0.4);
}
#create-form {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background-color: #000;
width: 500px;
height: 1500px;
background-color: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="btn btn-primary" id="addCustomerBtn">Click</div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
</div>
<div id="myModal">
<div id="create-form">
<div class="green"></div>
<div class="yellow"></div>
</div>
</div>
Add overflow-y: scroll; to your modal class in the CSS.
$('#addCustomerBtn').on('click', function() {
// window.location.href = "http://dev.rabbijet.com/crm/create.html";
var modal = document.getElementById('myModal');
modal.style.display = "block";
})
body {
overflow: auto;
}
.black {
height: 200px;
width: 800px;
background-color: black;
}
.gray {
height: 200px;
width: 800px;
background-color: gray;
}
.green {
height: 700px;
background-color: green;
}
.yellow {
height: 700px;
background-color: yellow;
}
#addCustomerBtn {
font-size: 14px;
width: 120px;
border: 1px solid #20ACB3;
background-color: #20ACB3;
}
#myModal {
display: none;
position: fixed;
overflow-y: scroll;
/* Stay in place */
z-index: 999;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
background-color: rgba(0, 0, 0, 0.4);
}
#create-form {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background-color: #000;
width: 500px;
height: 1500px;
background-color: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="btn btn-primary" id="addCustomerBtn">Click</div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
</div>
<div id="myModal">
<div id="create-form">
<div class="green"></div>
<div class="yellow"></div>
</div>
</div>
This answer is very rough, but basically what you do is allow overflow on the modal container, and when the button is clicked you disallow overflow on the parent container. When you close the modal, remember to remove the .overflow-hidden class I made from the document body. Also, if you are using jQuery use it. It is popular because it makes many things, like applying styles, easier.
$('#addCustomerBtn').on('click', function() {
// window.location.href = "http://dev.rabbijet.com/crm/create.html";
var modal = $('#myModal');
modal.css('display','block');
$(document.body).toggleClass('overflow-hidden');
})
body {
overflow: auto;
}
.overflow-hidden {
overflow: none;
}
.black {
height: 200px;
width: 800px;
background-color: black;
}
.gray {
height: 200px;
width: 800px;
background-color: gray;
}
.green {
height: 700px;
background-color: green;
}
.yellow {
height: 700px;
background-color: yellow;
}
#addCustomerBtn {
font-size: 14px;
width: 120px;
border: 1px solid #20ACB3;
background-color: #20ACB3;
}
#myModal {
display: none;
position: absolute;
/* Stay in place */
z-index: 999;
/* Sit on top */
left: 0;
top: 0;
bottom: 0;
/* Full width */
right: 0;
/* Full height */
background-color: rgba(0, 0, 0, 0.4);
overflow: auto;
}
#create-form {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background-color: #000;
width: 500px;
height: 1500px;
background-color: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="btn btn-primary" id="addCustomerBtn">Click</div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
<div class="black"></div>
<div class="gray"></div>
</div>
<div id="myModal">
<div class="close-button">X</div>
<div id="create-form">
<div class="green"></div>
<div class="yellow"></div>
</div>
</div>
.table {
display: table;
width: 10rem;
background-color: yellow;
}
.table-row {
display: table-row;
height: 100%;
width: 100%;
}
.table-cell {
display: table-cell;
height: 100%;
width: 50%;
position: relative;
}
.cell-top-div {
height: 1.5rem;
border-left: 1rem solid red;
}
.cell-bottom-div {
position: absolute;
top: 1.5rem;
bottom: 0;
width: 100%;
border-left: 1rem solid black;
}
.cell-right-div {
background-color: green;
height: 5rem;
}
<div class="table">
<div class="table-row">
<div class="table-cell">
<div class="cell-top-div"> </div>
<div class="cell-bottom-div"> </div>
</div>
<div class="table-cell">
<div class="cell-right-div"> </div>
</div>
</div>
</div>
Chrome & Firefox:
Internet Explorer:
Height of cell-top-div is fixed whereas height of cell-bottom-div is variable and depends on right cell. I want to add a left border to cell-bottom-div but in IE browser height is calculated as 0.
Simplest solution I've found is to remove position:relative from .table-cell and add it to .table. I think by doing this the table is determining the height vs. the table-cell which is only being given height by its contents.
.table {
display: table;
width: 10rem;
background-color: yellow;
position: relative;
}
.table-row {
display: table-row;
height: 100%;
width: 100%;
}
.table-cell {
display: table-cell;
height: 100%;
width: 50%;
}
.cell-top-div {
height: 1.5rem;
border-left: 1rem solid red;
}
.cell-bottom-div {
position: absolute;
top: 1.5rem;
bottom: 0;
width: 100%;
border-left: 1rem solid black;
}
.cell-right-div {
background-color: green;
height: 5rem;
}
<div class="table">
<div class="table-row">
<div class="table-cell">
<div class="cell-top-div"> </div>
<div class="cell-bottom-div"> </div>
</div>
<div class="table-cell">
<div class="cell-right-div"> </div>
</div>
</div>
</div>
I want the left column (#left) to have overflow-y: scroll and overflow-x: visible. However, the overflow-x ends up being scroll when I test it despite the code saying different. What am I doing wrong? Thanks.
$(document).ready(function(){
$("#title").click(function(){
$("#title").hide();
});
$("#one").click(function(){
$("#one").addClass("open");
$("#oneBottom").addClass("clicked");
$("#two").removeClass("open");
$("#twoBottom").removeClass("clicked");
$("#three").removeClass("open");
$("#threeBottom").removeClass("clicked");
$("#four").removeClass("open");
$("#fourBottom").removeClass("clicked");
$("#five").removeClass("open");
$("#fiveBottom").removeClass("clicked");
});
$("#two").click(function(){
$("#two").addClass("open");
$("#twoBottom").addClass("clicked");
$("#one").removeClass("open");
$("#oneBottom").removeClass("clicked");
$("#three").removeClass("open");
$("#threeBottom").removeClass("clicked");
$("#four").removeClass("open");
$("#fourBottom").removeClass("clicked");
$("#five").removeClass("open");
$("#fiveBottom").removeClass("clicked");
});
$("#three").click(function(){
$("#three").addClass("open");
$("#threeBottom").addClass("clicked");
$("#one").removeClass("open");
$("#oneBottom").removeClass("clicked");
$("#two").removeClass("open");
$("#twoBottom").removeClass("clicked");
$("#four").removeClass("open");
$("#fourBottom").removeClass("clicked");
$("#five").removeClass("open");
$("#fiveBottom").removeClass("clicked");
});
$("#four").click(function(){
$("#four").addClass("open");
$("#fourBottom").addClass("clicked");
$("#one").removeClass("open");
$("#oneBottom").removeClass("clicked");
$("#two").removeClass("open");
$("#twoBottom").removeClass("clicked");
$("#three").removeClass("open");
$("#threeBottom").removeClass("clicked");
$("#five").removeClass("open");
$("#fiveBottom").removeClass("clicked");
});
$("#five").click(function(){
$("#five").addClass("open");
$("#fiveBottom").addClass("clicked");
$("#one").removeClass("open");
$("#oneBottom").removeClass("clicked");
$("#two").removeClass("open");
$("#twoBottom").removeClass("clicked");
$("#three").removeClass("open");
$("#threeBottom").removeClass("clicked");
$("#four").removeClass("open");
$("#fourBottom").removeClass("clicked");
});
});
.open{
margin-left: 124% !important;
margin-top: 18% !important;
width: 187% !important;
height: 80% !important;
font-size: 250% !important;
}
.clicked{
border: red solid 3px !important;
}
html{
width: 100%;
height: 100%;
margin: 0px;
border: 0px;
}
body{
width: 100%;
height: 100%;
margin: 0px;
border: 0px;
}
#title{
height: 10%;
width: 100%;
margin-bottom: 1%;
background-color: rgba(0, 0, 255, 0.5);
}
h1{
text-align: center;
}
#left{
width: 30%;
height: 100%;
position: absolute;
overflow-y: scroll;
overflow-x: visible;
}
#right{
width: 70%;
height: 100%;
position: absolute;
margin-left: 30%;
border-left: solid 2px black;
}
.card{
height: 20%;
width: 80%;
margin-left: 10%;
position: absolute;
background-color: blue;
border-radius: 5px;
border: grey solid 2px;
}
.first{
margin-top: 6.5%;
}
#one{
background-color: green;
}
.second{
margin-top: 50%;
}
#two{
background-color: green;
}
.third{
margin-top: 93%;
}
#three{
background-color: green;
}
.fourth{
margin-top: 136%;
}
#four{
background-color: green;
}
.fith{
margin-top: 179%;
}
#five{
background-color: green;
}
#main{
width: 80%;
height: 80%;
margin-left: 10%;
margin-top: 7.5%;
background-color: white;
border-radius: 5px;
border: grey solid 3px;
opacity: 0.5;
}
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<div id="title">
<h1>Blah Blah Blah</h1>
</div>
<div id="left">
<div class="card first" id="oneBottom">
<h1>Hello</h1>
<p>Heljaldf</p>
</div>
<div class="card first" id="one">
<h1>Hello</h1>
<p>Heljaldf</p>
</div>
<div class="card second" id="twoBottom">
<h1>Sup</h1>
</div>
<div class="card second" id="two">
<h1>Sup</h1>
</div>
<div class="card third" id="threeBottom">
</div>
<div class="card third" id="three">
</div>
<div class="card fourth" id="fourBottom">
</div>
<div class="card fourth" id="four">
</div>
<div class="card fith" id="fiveBottom">
</div>
<div class="card fith" id="five">
</div>
</div>
<div id="right">
<div id="main">
</div>
</div>
</body>
</html>
The issue you're having with #left is that you're mixing visible with scroll. Because you're mixing values it's going to treat visible as auto instead.
Check out the W3 documentation on this here: http://www.w3.org/TR/css3-box/#collapse-scroll