Fundación CSS
El desplazamiento suave permite desplazarse a la sección específica dentro de la página web sin actualizar. Podemos habilitar el Desplazamiento suave en enlaces internos, simplemente agregando el atributo data-smooth-scroll al contenedor principal. Cada componente requiere una identificación única.
Atributo de desplazamiento suave de Foundation CSS:
- data-smooth-scroll: este atributo debe agregarse al contenedor principal para habilitar el desplazamiento suave al enlace requerido
Clase Foundation CSS Smooth Scroll:
- menu: Esta clase se utiliza para crear un menú de navegación que contiene los enlaces a las páginas importantes.
Sintaxis:
<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>
Ejemplo 1 : este ejemplo describe el desplazamiento suave con navegación fija en Foundation CSS.
HTML
<!DOCTYPE html> <html> <head> <title>Foundation CSS Smooth Scroll</title> <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css" crossorigin="anonymous" /> <script src= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"> </script> <script src= "https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" 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>
Salida :
Ejemplo 2 : Este ejemplo describe la configuración de desplazamiento suave directamente con un enlace individual.
HTML
<!DOCTYPE html> <html> <head> <title>Foundation CSS Smooth Scroll</title> <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css" crossorigin="anonymous" /> <script src= "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"> </script> <script src= "https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" 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>
Producción:
Referencia: https://get.foundation/sites/docs/smooth-scroll.html
Publicación traducida automáticamente
Artículo escrito por lizzywizzy366 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA