Foundation CSS Smooth Scroll
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is built on Saas-like bootstrap. It is more sophisticated, flexible, and easily customizable. It also comes with CLI, so it’s easy to use it with module bundlers. It offers the Fastclick.js tool for faster rendering on mobile devices.
The Smooth Scroll enables scrolling to the specific section within the webpage without refreshing. We can enable the Smooth Scroll on internal links, just by adding the data-smooth-scroll attribute to the parent container. Each component requires a unique ID.
Foundation CSS Smooth Scroll Attribute:
- data-smooth-scroll: This attribute must be added to the parent container, in order to enable Smooth Scroll to the required link
Foundation CSS Smooth Scroll Class:
- menu: This class is used to create a navigation menu that contains the links to the important pages.
Syntax:
<ul class="menu" data-smooth-scroll> <li> <a href="#first">Content 1</a> </li> <li> <a href="#second">Content 2</a> </li> </ul> <div class="sections"> <section id="first"> Section 1 Content </section> <section id="second"> Section 2 Content </section> </div>
Example 1: This example describes the smooth scroll with sticky navigation in Foundation CSS.
HTML
<!DOCTYPE html> < html > < head > < title >Foundation CSS Smooth Scroll</ title > < link rel = "stylesheet" href = crossorigin = "anonymous" /> < script src = </ script > < script src = crossorigin = "anonymous" > </ script > </ head > < body > < div data-sticky-container> < div class = "top-bar" data-sticky data-margin-top = "0" id = "example-menu" > < div class = "top-bar-left" > < ul class = "menu" > < li class = "menu-text" > GeeksforGeeks </ li > </ ul > </ div > < div class = "top-bar-right" > < ul class = "menu" data-smooth-scroll> < li >< a href = "#tutorial" >Tutorials</ a ></ li > < li >< a href = "#job" >Jobs</ a ></ li > < li >< a href = "#events" >Events</ a ></ li > </ ul > </ div > </ div > </ div > < div class = "grid-x grid-padding-x demo-toggle-title" > < div class = "cell" > < h3 >Smooth Scroll tutorial</ h3 > < div class = "sections" > < section id = "tutorial" > < h4 >tutorials</ h4 > < li >Practice DS & Algo.</ li > < li >Algorithms</ li > < li >Data Structures></ li > < li >Interview Corner</ li > < li >Languages</ li > < li >CS Subjects</ li > < li >GATE</ li > < li >Web Technologies</ li > < li >Software Designs</ li > < li >School Learning</ li > < li >CS Exams/PSUs</ li > < li >Student</ li > </ section > < section id = "job" > < h4 >jobs</ h4 > < p > GeeksforGeeks has built a gigantic network of geeks from all over the globe, through various online and offline courses. We are offering IT companies to hire talented engineers with us at no cost of acquisition. </ p > </ section > < section id = "events" > < h4 >events</ h4 > </ section > </ div > </ div > </ div > </ body > </ html > |
Output:
Example 2: This example describes the setting up smooth scroll directly with an individual link.
HTML
<!DOCTYPE html> < html > < head > < title >Foundation CSS Smooth Scroll</ title > < link rel = "stylesheet" href = crossorigin = "anonymous" /> < script src = </ script > < script src = crossorigin = "anonymous" > </ script > </ head > < body > < center > < h1 style = "color: green" >GeeksforGeeks</ h1 > < h3 >Foundation css smooth scroll</ h3 > </ center > < div class = "grid-x grid-padding-x" > < div class = "cell" > < a href = "#foundation" data-smooth-scroll>Foundation CSS</ a > </ div > </ div > < div class = "grid-x grid-padding-x" > < div class = "cell" > < div class = "sections" > < section id = "dummy" > < h4 >Introduction</ h4 > < p > A Foundation is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. The framework is based on bootstrap, which is similar to SaaS. It’s more complex, versatile, and configurable. It also comes with a command-line interface, making it simple to use with module bundlers. Email framework provides you with responsive HTML emails, which can be read on any device. Foundation for Apps allows you to build fully responsive web applications. </ p > </ section > </ div > </ div > </ div > < div class = "grid padding-gutters grid-padding-x" > < div class = "cell" > < div class = "sections" > < section id = "foundation" > < h4 >Foundation CSS native meter</ h4 > < p > parameters: value: The numeric value that is currently in use. If the lowest and maximum values (min and max attributes) are defined, this must be between them. The value is 0 if the value is undefined or faulty. The value is equal to the nearest end of the range if supplied but not within the range defined by the min and max attributes. Note on usage: Unless the value attribute's value is between 0 and 1 (inclusive), the min and max attributes should be used to specify the range such that the value attribute's value is contained within it. min: The measured range's bottom numeric bound. If the maximum value (max attribute) is supplied, this must be smaller. The minimum value is 0 if none is given. low: The lower numeric bound of the measured range's bottom end. If any are supplied, this must be larger than the lowest value (min attribute) and less than the high and maximum values (high attribute and max attribute, respectively). The low value is equal to the minimum value if it is undefined or less than the minimum value. high: The lower numeric bound of the measured range's high end. If any are supplied, this must be less than the maximum value (max attribute) and larger than the low value and lowest value (low attribute and min attribute, respectively). If the high value is undefined or more than the maximum value, the high value equals the maximum value. optimum: The ideal numeric value is indicated by this characteristic. It has to be in the acceptable range (as defined by the min attribute and max attribute). It indicates where along the range is regarded ideal when combined with the low and high attributes. For example, if the min attribute and the low attribute are both available, the lower range is selected. max: The measured range's top numeric bound. If a minimum value (min attribute) is provided, this must be larger. The maximum value is 1 if no value is supplied. </ p > </ section > </ div > </ div > </ div > </ body > </ html > |
Output:
Reference: https://get.foundation/sites/docs/smooth-scroll.html
Please Login to comment...