I've been struggling thinking of the context of this question, I'll try do my best!
I'm working on a page which I set its nav position
to fixed
so it stick to the screen while scrolling, and set the href
attributes of the a
elements to some Ids, so the user can walk through the page by clicking the nav links. The problem is when I click the link which goes to the first part of the page, its content become hidden behind the nav bar. So I thought I may have to define new "coordinates" to the page to resettle its elements:
The markup of the nav bar:
<nav id="navbar">
<ul id="navItems">
<li><a id="wel">Welcome</a></li>
<li><a id="SendMsg">Send me a message</a></li>
<li><a id="myResume">My Resume</a></li>
</ul>
</nav>
The markup of the very first content:
<div class="Mask1"></div>
<div id="intro">
<div id="name">
<h1 id="moh">Mohamed Ahmed Eshawaf
</h1>
</div>
<br />
<div id="pos">
<h3>.NET Developer</h3>
</div>
<br />
<div id="pos2">
<h3>Web Designer</h3>
</div>
<br />
<div id="pos3">
<p style="font-size:24pt">
Some paragraph here!
</p>
</div>
</div>
CSS:
#navbar {
background-color: #019AA4;
border-bottom-left-radius: 50px;
border-bottom-right-radius: 50px;
margin: 0 auto;
width: 1000px;
height: 50px;
position: fixed;
right: 13%;
top: 0px;
z-index: 888;
display: block;
}
ul#navItems li {
float: left;
line-height: 48px;
margin-right: 30px;
}
#navItems {
position: absolute;
top: 0px;
right: 150px;
list-style-type: none;
width: 615px;
height: 50px;
margin: 0 auto;
}
I used jQuery code like that to walk through the page:
$("#wel").click(function () {
$('html, body').animate({
scrollTop: $(".Mask1").offset().top
}, 2000);
this is my last try code, which I added a div
tag with id
"mask" and set its width to 50px, so rather linking the original content I linked to this pseudo element.
.Mask1
{
width:50px;
}
I hope my problem is clear now, let me know please if it's not. My problem is: when I click the link Welcome in the navigation bar my name (the element with id moh) becomes hidden behind it, I want to position it directly under the navbar. *You can suggest better question wording.