JSFiddle - React, Tailwind, and code Playground
http://stackoverflow.com/questions/12238099/make-named-anchor-bookmarks-appear-always-at-top-of-the-screen-when-clicked
by Mark
HTML
<ul class="sub_navi">
<li><a href="#sheds_housing">Sheds & Housing</a></li>
<li><a href="#feed_fodder">Feed & Fodder</a></li>
<li id="gonnaclickhere"><a href="#med_vac">Medication & Vaccination</a></li>
</ul>
<div id="content">
<div id="content_pic">
<img src="images/cattle/cattle_main.jpg" width="400" height="300" alt="Cattle Main" title="Cattle Main" />
</div>
<p>Pak United Food Services Ltd., (PUFS) has earned a creditable name and become a major player in the animal husbandry market by building upon Pakistan's large livestock population. Introducing the concept of corporate cattle farming on scientific lines, the conglomerate uses a livestock development policy consisting of innovative strategies and action plans with the intention of bringing about a radical change in the current livestock production system. The cattle farms are established on rich and fertile acres of land and consist of an impressive and mixed herd of cows/buffalos and sheep/goats.</p>
<p>A hybrid meat breed is developed by crossing the local indigenous breeds which are predominately draught/milch animals with high meat yielding animals from other parts of the world. A herd management system is incorporated to improve record keeping and obtain information for bench marking decisions. The farms employ a state of the art feedlot design involving the integration of the standard components into a fully functional operating system. This consists of housing, feeding, watering, health-care and cattle effluent & manure management systems, making them well known across the country.</p>
<div id="sheds_housing">
<h1>sheds & housing</h1>
<img src="images/cattle/sheds_housing.png" width="150" height="150" alt="Sheds & Housing" title="Sheds & Housing" />
<p>The housing for the animals utilizes a proper lay out for the farm buildings while keeping in view the environment, climate and wind direction. Sheds, pens and paddocks are...
JavaScript
function isScrolledIntoView(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
//return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop));
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
var elem_that_hides_dummydiv = $('#content div:first');
var elem_that_shows_dummydiv = $('#content div:last');
$(window).scroll(function() {
if (isScrolledIntoView(elem_that_hides_dummydiv)) {
$('#dummydiv').hide()
}
});
$('#gonnaclickhere').click(function() {
$('#dummydiv').css({
'height': (elem_that_shows_dummydiv.offset().top) + 'px'
}).show()
})