代码之家  ›  专栏  ›  技术社区  ›  Zolez

Wordpress-视差效果[关闭]

  •  -2
  • Zolez  · 技术社区  · 12 年前

    我想在wordpress中实现视差效果,类似于 marcfitt.com 。当你向下滚动转盘时,转盘保持固定,较低的内容在其上滚动。我如何实现类似的功能?

    1 回复  |  直到 12 年前
        1
  •  0
  •   Philip Pittle    12 年前

    本博客有一个逐步为您的网站添加视差的指南: http://wevostudio.com/wordpress-parallax-implementation/

     <?php
    
        function add_theme_scripts() {
    
            wp_enqueue_script( 'parallax', get_template_directory_uri() . '/js/jquery.parallax-1.1.3.js', array(), '1.1.3', true );
    
                        wp_enqueue_script( 'nicescroll', get_template_directory_uri() . '/js/jquery.nicescroll.min.js', array(), '3.5.1', true );
    
        }
    
        add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
    
    ?>
    
    <?php
        function custom_post_type() {
            $labels = array( 
                'name'               => _x( 'Parallax', 'general name' ),
                'singular_name'      => _x( 'Page', 'singular name' ),
                'add_new'            => _x( 'Add New', 'parallax' ),
                'add_new_item'       => __( 'Add New Page' ),
                'edit_item'          => __( 'Edit Page' ),
                'new_item'           => __( 'New Page' ),
                'all_items'          => __( 'All Pages' ),
                'view_item'          => __( 'View Page' ),
                'search_items'       => __( 'Search Pages' ),
                'not_found'          => __( 'No pages found' ),
                'not_found_in_trash' => __( 'No pages found in the Trash' ),
                'parent_item_colon'  => '',
                'menu_name'          => 'Parallax'
            );
            $args = array( 
                'labels'        => $labels,
                'public'        => true,
                'menu_position' => null,
                'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'page-attributes' ),
                'has_archive'   => true,
            );
            register_post_type(__( 'parallax' ), $args); 
        }
        add_action( 'init', 'custom_post_type' );
    ?>