diff --git a/docs/js/custom.js b/docs/js/custom.js
new file mode 100644
index 0000000000000000000000000000000000000000..94dc54aa2260ad375418e977bc3ae6554678f278
--- /dev/null
+++ b/docs/js/custom.js
@@ -0,0 +1,9 @@
+
+// Automatically scroll the navigation menu to the active element
+//   https://github.com/civicrm/civicrm-dev-docs/issues/21
+$('.wy-nav-side')
+  .scrollTop(
+    $('li.toctree-l1.current').offset().top -
+    $('.wy-nav-side').offset().top -
+    80
+  );
diff --git a/mkdocs.yml b/mkdocs.yml
index 9fe1c0d87914519763c1f88d85df273ca05c762e..c027bd28f08838b1fdf108685e19712457700b42 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -3,6 +3,8 @@ repo_url: https://github.com/civicrm/civicrm-dev-docs
 site_description: A guide for CiviCRM developers.
 site_author: The CiviCRM community
 theme: readthedocs
+extra_javascript:
+  - js/custom.js
 pages:
 - Home: index.md
 - Basics: