{"id":8687,"date":"2021-09-03T12:15:25","date_gmt":"2021-09-03T12:15:25","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=8687"},"modified":"2021-09-03T12:15:26","modified_gmt":"2021-09-03T12:15:26","slug":"bootstrap-component-scrollspy","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/","title":{"rendered":"Bootstrap:-Component &#8220;Scrollspy&#8221;"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The Bootstrap 4 scrollspy is a navigation mechanism that automatically highlights the nav links based on the scroll position to indicate the visitor where they are currently on the page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to create Scrollspy:-<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>use<strong> nav component or list group<\/strong>.<\/li><li>Scrollspy requires<strong> position: relative<\/strong>; inside style section.<\/li><li>Add <strong>data-spy=&#8221;scroll&#8221;<\/strong> to the element that should be used as the scrollable area(<strong>inside body tag<\/strong>).<\/li><li>Add <strong>data-target<\/strong> with value<strong> id|class<\/strong> (.navbar). this is important to make sure that the navbar is <strong>connected with the scrollable area.<\/strong><\/li><li>inside<strong> &lt;div id=&#8221;name&#8221; ><\/strong> matches link with the nav item<strong> &lt;a href=&#8221;#name&#8221;><\/strong>.<\/li><li>Add<strong> data-offset =&#8221;30&#8243;<\/strong> specifies the number of pixels to offset from top when calculating the position of scroll.<\/li><\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/dd7d6694e620de758683b9df692170ab.js\"><\/script>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/index-3.html\"> Scrollspy Simple Example<\/a><a href=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/index-3.html\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"575\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1024x575.png\" alt=\"\" class=\"wp-image-8709\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1024x575.png 1024w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-300x169.png 300w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-768x432.png 768w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1536x863.png 1536w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy.png 1922w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"575\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/part2-1024x575.png\" alt=\"\" class=\"wp-image-8713\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/part2-1024x575.png 1024w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/part2-300x169.png 300w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/part2-768x432.png 768w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/part2-1536x863.png 1536w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/part2.png 1922w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The Bootstrap 4 scrollspy is a navigation mechanism that automatically highlights the nav links based on the scroll position to [&hellip;]<\/p>\n","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5670],"tags":[6682,1122,6680,373,593,130,4552,6681,6679,213],"class_list":["post-8687","post","type-post","status-publish","format-standard","hentry","category-bootstrap","tag-bootstrap-in-scmgalaxy","tag-guide","tag-how-to-create-scrollspy-in-bootstrap4","tag-perforce","tag-process","tag-scmgalaxy","tag-scmgalaxy-tutorials","tag-scrollspy-in-bootstrap","tag-scrollspy-in-bootstrap4","tag-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Bootstrap:-Component &quot;Scrollspy&quot; - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bootstrap:-Component &quot;Scrollspy&quot; - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"The Bootstrap 4 scrollspy is a navigation mechanism that automatically highlights the nav links based on the scroll position to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-03T12:15:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-03T12:15:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1024x575.png\" \/>\n<meta name=\"author\" content=\"vikashdev k\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"vikashdev k\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/\"},\"author\":{\"name\":\"vikashdev k\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\"},\"headline\":\"Bootstrap:-Component &#8220;Scrollspy&#8221;\",\"datePublished\":\"2021-09-03T12:15:25+00:00\",\"dateModified\":\"2021-09-03T12:15:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/\"},\"wordCount\":125,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/scrollspy-1024x575.png\",\"keywords\":[\"bootstrap in scmgalaxy\",\"Guide\",\"how to create scrollspy in bootstrap4\",\"Perforce\",\"Process\",\"scmgalaxy\",\"scmGalaxy Tutorials\",\"scrollspy in bootstrap\",\"scrollspy in bootstrap4\",\"Tutorial\"],\"articleSection\":[\"Bootstrap\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/\",\"name\":\"Bootstrap:-Component \\\"Scrollspy\\\" - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/scrollspy-1024x575.png\",\"datePublished\":\"2021-09-03T12:15:25+00:00\",\"dateModified\":\"2021-09-03T12:15:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/scrollspy.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/scrollspy.png\",\"width\":1922,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/bootstrap-component-scrollspy\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bootstrap:-Component &#8220;Scrollspy&#8221;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\",\"name\":\"vikashdev k\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"caption\":\"vikashdev k\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/vikashdev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bootstrap:-Component \"Scrollspy\" - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/","og_locale":"en_US","og_type":"article","og_title":"Bootstrap:-Component \"Scrollspy\" - scmGalaxy","og_description":"The Bootstrap 4 scrollspy is a navigation mechanism that automatically highlights the nav links based on the scroll position to [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/","og_site_name":"scmGalaxy","article_published_time":"2021-09-03T12:15:25+00:00","article_modified_time":"2021-09-03T12:15:26+00:00","og_image":[{"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1024x575.png","type":"","width":"","height":""}],"author":"vikashdev k","twitter_card":"summary_large_image","twitter_misc":{"Written by":"vikashdev k","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/"},"author":{"name":"vikashdev k","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515"},"headline":"Bootstrap:-Component &#8220;Scrollspy&#8221;","datePublished":"2021-09-03T12:15:25+00:00","dateModified":"2021-09-03T12:15:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/"},"wordCount":125,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1024x575.png","keywords":["bootstrap in scmgalaxy","Guide","how to create scrollspy in bootstrap4","Perforce","Process","scmgalaxy","scmGalaxy Tutorials","scrollspy in bootstrap","scrollspy in bootstrap4","Tutorial"],"articleSection":["Bootstrap"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/","name":"Bootstrap:-Component \"Scrollspy\" - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy-1024x575.png","datePublished":"2021-09-03T12:15:25+00:00","dateModified":"2021-09-03T12:15:26+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/scrollspy.png","width":1922,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/bootstrap-component-scrollspy\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Bootstrap:-Component &#8220;Scrollspy&#8221;"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515","name":"vikashdev k","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","caption":"vikashdev k"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/vikashdev\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/8687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=8687"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/8687\/revisions"}],"predecessor-version":[{"id":8714,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/8687\/revisions\/8714"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=8687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=8687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=8687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}