I have a fixed position menu bar at the top of the page which is (lets say) 50px high, the body has a top margin of 50px also. Above the menu bar, there can be an error message which can vary in height. This variation means that the margin ontop of the body will need to change accordingly.
I would like to avoid the use of javascript here but if it's not possible I will use it as a last resort.
An example of what the page will look like is at http://subjectplanner.co.uk/Me/ . If you click on the error message, it will dissapear and that is how the page should look.
HTML Code:
<div id="NavWrapper">
<div id="NavErrorWrapper" class="Notification">
<div id="NavError">You must be logged in!</div>
</div>
<div id="NavBar">
<a href="/index" id="NavLogo"><img src="logo.png" /></a>
<div class="HideIfJavaOff"><a href="#" id="NavMenu"><img src="menu.png" /></a></div>
<div class="MenuClear"></div>
<!-- MENU LIST HERE -->
</div>
</div>
<!-- End Floating Navigation Bar -->
<!-- Responsive Wrapper -->
<div id="MainWrapper">
<!-- CONTENT HERE -->
</div>
</body>
CSS Code:
#NavWrapper{
width: 100%;
z-index: 1;
top: 0;
position: fixed;
height:70px;
}
#NavErrorWrapper{
z-index: 3;
text-align: center;
width: 100%;
padding: 7px;
background-color: rgb(255, 148, 148);
border-bottom-style: solid;
border-bottom-color: rgb(252, 88, 88);
border-bottom-width: 3px;
display: block;
}
#NavError{
width: 100%;
max-width: 900px;
margin: 0 auto;
}
#NavBar{
overflow: hidden;
display: block;
width: inherit;
max-width: 900px;
z-index: 2;
height:auto;
margin: 0 auto;
background-color: #fff;
}