I've got an issue with styling using CSS. I have a website which constists of 4 major areas and 1 overall area. I simplified the code and added a color code to each area to get a quicker overview, but the main areas with there css looks like this:
.madegamesDiv {
position: fixed;
z-index: 1;
top: 0px;
left: 0px;
width: 100%;
min-width: 1200px;
height: 34px;
background-color: #778013;
border-bottom: 1px solid #39950E;
}
.allDiv {
position: fixed;
top: 35px;
left: 0px;
width: 100%;
height: 100%;
min-width: 1200px;
min-height: 850px;
background-color: #39950E;
overflow: scroll;
}
.leftDiv {
position: absolute;
z-index: 1;
height: 775px;
float: left;
width: 200px;
overflow: hidden;
position: fixed;
padding: 5px;
background-color: #FFFF00;
}
.topDiv {
min-width: 1000px;
position: fixed;
left: 200px;
top: 35px;
height: 150px;
overflow: hidden;
background-color: #FF00FF;
}
.mainDiv {
width: 100%;
min-width: 800px;
max-width: calc(100% - 500px);
background-color: #FFFFFF;
position: fixed;
left: 50%;
margin-left: calc((100% - 500px)/2*(-1));
top: 160px;
height: calc(100% - 180px - 27px);
overflow: auto;
border: 1px solid #225909;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
padding: 10px;
background-color: #FF0000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<body>
<div id="madegamesDiv" class="madegamesDiv"></div>
<div id="all" class="allDiv">
<div id="left" class="leftDiv">
<p>Menu Area</p>
</div>
<div style="position:absolute;left:200px;height:100%;top:0px;">
<div id="top" class="topDiv">
<p>Top Area with logo and other stuff</p>
</div>
<div id="main" class="mainDiv">
<h1>Main Area</h1>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
<p>Here is a lot of text and content</p>
</div>
</div>
</div>
</body>
The main area main is the area with the most content. It needs to be scrollable.
But my problem is now, how could I realize, when the browser window is too small, that all areas are displayed correctly?
I thought on making the overall area all scrollable with CSS
overflow:auto; or overflow:scroll;. But this does not work. I think the problem is, that the other areas are position:fixed and so the overall area all does not recognize the size of the other areas. Hard to explain, I hope, you can understand, what I try to explain.
Is there a way to display scrollbars, when the window is too small?
Thanks in advance for your help. If some code is missing or something is unclear, please feel free to ask.
position:absoluteandposition:fixed, and it should be used very rarely, where the layout of the page is not "absolute" or "fixed". These are usually used on UI elements but never to a page layout. (It doesn't mean it's not possible) It seems that based on your programming style, you're very new at this. I would suggest to study the Bootstrap framework, understand how it's done, and apply it to the problem above. What you're doing is just a standard page layout, Bootstrap might help.