📜  如何使用pagemap插件设计网页导航图?

📅  最后修改于: 2021-10-29 04:29:00             🧑  作者: Mango

在本文中,我们将学习如何使用 pagemap插件为单页网站的导航系统设计迷你地图。这个插件完全是一个基于 HTML、JavaScript 和 CSS 的工具。

请下载用于代码实现的预编译库文件。

开发者可以通过以下 CSS 代码来固定地图在屏幕上的位置。添加上述HTML代码的样式部分。

#map {
    position: fixed;
    top: 0;
    right: 0;
    width: 200px;
    height: 100%;
    z-index: 100;
}

小地图的初始化和样式在代码的脚本部分处理。以下代码片段仅作为示例提供给开发人员,他们可以根据需要进行更改。

pagemap(document.querySelector('#map'), {
     /* Another HTML container ID  */
    viewport: document.querySelector('#container'),
    styles: {
        'h1,a': 'rgba(0,0,0,0.10)',
        'h2,h3,h4': 'rgba(0,0,0,0.08)'
    },
    back: 'rgba(0,0,0,0.02)',
    view: 'rgba(0,0,0,0.05)',
    drag: 'rgba(0,0,0,0.10)',
    interval: 50
});

示例:以下代码演示了用于在网页右上角导航网页的小地图。将画布标签添加到您的 HTML 页面。



  

    
    
    

  

    
        
            

HTML

               

                  HTML stands for HyperText Markup                  Language.
It is used to design                  web pages using a markup language.                 
HTML is the combination of                  Hypertext and Markup language.             

                           

                  Hypertext defines the link between                  the web pages.
A markup language                 is used to define the text document                  
within tag which defines the                  structure of web pages.             

               

                  HTML is a markup language that is                  used by
the browser to                  manipulate text,images,
and                  other content to display it in the                  required format.             

        

           
            

PHP

               

                The term PHP is an acronym for PHP:                  Hypertext Preprocessor.
PHP is                 a server-side scripting language                  designed specifically
for web                  development.             

                           

                PHP can be easily embedded in HTML                  files and HTML codes
can also                  be written in a PHP file.             

                           

                The thing that differentiates PHP                  with client-side
language like                  HTML is,PHP codes are executed on                  the
server whereas HTML codes                  are directly rendered on the browser.             

                           

                The term PHP is an acronym for PHP:                  Hypertext Preprocessor.
PHP is                 a server-side scripting language                  designed specifically
for web                  development.             

                           

                PHP can be easily embedded in HTML                  files and HTML codes can
also                  be written in a PHP file.             

                           

                The thing that differentiates PHP                  with client-side language
like                  HTML is,PHP codes are executed on                  the server
whereas HTML codes                 are directly rendered on the browser.             

        

           
            

CSS

               

                Cascading Style Sheets, fondly referred                  to as CSS,
is a simply designed                  language intended to simplify
                  the process of making web pages                  presentable.              

                           

                CSS allows you to apply styles to                  web pages.             

                           

                More importantly, CSS enables you to                  do this independent
of the HTML                  that makes up each web page.             

                           

                Cascading Style Sheets, fondly referred                  to as CSS,
is a simply designed                  language intended to simplify
the                 process of making web pages presentable.             

                           

                CSS allows you to apply styles to                  web pages.             

                           

                More importantly, CSS enables you to                  do this
independent of the HTML                  that makes up each web page.             

                           

                CSS allows you to apply styles to                  web pages.             

                           

                More importantly, CSS enables you to                  do this
independent of the HTML                  that makes up each web page.             

        

           
            

JavaScript

               

                  JavaScript is a lightweight, cross-                 platform and
interpreted                  scripting language.             

                           

                It is well-known for the development                  of web pages,
many non-browser                  environments also use it.             

                           

                JavaScript can be used for Client-side                  developments
as well as                  Server-side developments.             

               

                  JavaScript is a lightweight, cross-                 platform and
interpreted scripting                 language.             

                           

                It is well-known for the development                  of web pages,
many non-browser                  environments also use it.             

                           

                JavaScript can be used for Client-side                  developments
as well as Server-                 side developments.             

        

           
            

Python

               

                  Python is a high-level, general-purpose                 and a
very popular programming                  language.             

                           

                Python programming language (latest                  Python 3) is
being used in web                  development, Machine Learning applications,                 
along with all cutting edge technology                 in Software Industry.             

                           

                Python Programming Language is very well                  suited
for Beginners, also for                  experienced programmers with
other                  programming languages like C++ and Java.             

        
    
                          

输出: