I'm trying to develop a web app that works locally (don't know how to explain it, but it works like clipchamp in that it "works" on your computer) but that is irrelevant for now so I won't delve further in this area.
At the moment I'm having trouble with the layout of the page and its CSS rules. I have a header(div) that takes up 100% of the page's width, but is 25px high and sits at the top of the page; and a navbar(span) that should take up the remaining space in height (we'll get there later), has a width of 180px and sits on the left side of the page. The rest of the page is supposed to be where the content lies.
My problems are the following:
- Since I wanted both the header and the navbar to be fixed in their positions (so that the scrolling only occurs on the content div) I tried adding
position: fixed;
to their rules. However that resulted in the navbar resetting its position to the top left corner of the page, therefore overlapping with the header, so I moved the navbar from the top by 27px (h. of header + its border) and since I didn't know how to let the navbar take up the rest of the space left in height, I temporarily gave it a height of 97.2%. This is obviously bad, which is why I'm here. So, how can I make it so that this span takes up the remaining space automatically ? - After I'd done the above, I realized that the content div moved at top left corner of the page. I have no idea why this is happening. I tried moving the content div by a fixed amount as well in a similiar fashion to resolve this, which, again, is bad. So I have basically the same problem as before, except this time it's for both width and height.
I tried searching and checked out some of the solutions suggested to other users (was more intrigued by this solution here suggested by another user in this thread, but being new I didn't quite understand how I could adapt it to also include a vertical column next to the content div and therefore reverted my attempted changes to the code and tried sticking to what I understood).
So, here is the HTML code. The image in the header shouldn't be a problem, and the only script just keeps refreshing the page every 100ms. (note: the navbar is currently empty, but it's supposed to have an "arrow-menu" inside)
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="preview.js"></script>
</head>
<body>
<div id="header">
<span id="avatar">
<img id="avatarImage" src="assets/defaultProfile.png" width="20" height="20">
</span>
AnimeDB
<span id="lightText">Dev Mode</span>
</div>
<span id="navbar"></span>
<div id="content">
Content
</div>
</body>
</html>
And here's the CSS, but I removed the changes to navbar and content. Before you go on reading, I want to point out that I don't fully understand yet some of the properties I've used here (mainly float and display. I have a very rough idea of how both work though).
html, body {
height: 100%;
margin: 0;
padding: 0;
}
body{
background-color: #D3D3D3;
}
#header {
display: inline-block;
color: white;
background-color: #41B1E1;
width: 100%;
height: 25px;
font-family: 'Segoe UI', Arial, sans-serif;
font-weight: bold;
font-size: 17px;
border-bottom: 2px solid white;
/*box-shadow: 0 3px 5px #9f9f9f;*/
}
#avatar {
float: left;
background-color: #0071BC;
color: white;
width: 30px;
height: 25px;
padding: 0 5px 0 5px;
border-right: 3px solid #71C5E9;
margin-right: 5px;
}
#avatarImage {
margin: 2px 5px;
}
#lightText {
color: rgba(255, 255, 255, 0.5);
}
#navbar {
float: left;
width: 180px;
height: 97.2%;
background-color: #A5A5A5;
border-right: 2px solid white;
}
#content {
background-color: greenyellow;
}
I hope I've been clear enough in explaining my problems and my thought process, and that I can learn something new from this experience.