doue2666 2015-08-21 20:51
浏览 63
已采纳

静态html页面不正常

I have a situation trying to implement this codepen into a static wordpress html home page.

this is my page-splash.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My sweet new splash page</title>
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/splash_assets/splash.css">
    <script type="text/javascript" src="http://www.neuegrid.com/wp-includes/js/jquery/jquery.js"></script>
    <script type="text/javascript" src="http://www.neuegrid.com/wp-includes/js/jquery/ui/core.min.js"></script>
    <script src="<?php echo get_template_directory_uri(); ?>/splash_assets/mynewmenu.js"></script>
</head>
<body>

<nav>
  <ul>
    <li><a href="http://www.neuegrid.com/">Home</a></li>
    <li><a href="http://www.neuegrid.com/portfolio">Portfolio</a></li>
    <li><a href="http://www.neuegrid.com/about-us/">About</a></li>
  </ul>
    <div id='menuRight'>
       <div>
           Home
           <img src='http://images5.fanpop.com/image/photos/31100000/random-space-space-31155586-598-398.jpg' />
       </div>
      <div>
          Portfolio
          <img src='http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg'/>
      </div>
      <div>
          About
          <img src='http://images5.fanpop.com/image/photos/31100000/random-space-space-31155586-598-398.jpg'/>
      </div>
    </div>
</nav>

</body>
</html>

Also I've created a folder splash_assets in the same dir as the above mentioned page, containing mynewmeny.js:

// mynewmenu implementation
jQuery(function($){ 
    var height, index, prevIndex;

    $('nav ul li').mouseover(function(e){
        //Set the aesthetics (similar to :hover)
        $('nav ul li').removeClass('hovered');
        $(this).addClass('hovered');

        //Gets relevant data required for scrolling of menuRight    
        height = $("#menuRight").css("height").replace('px','');
        index = $(this).index();

        //If the category button (from the navlist) has changed
        if (index != prevIndex){
            $("#menuRight").stop();

            $("#menuRight").animate({"scrollTop":height*index}, 800, 'easeOutBounce'); //This requires jQuery UI for easing options.
            prevIndex = index;
        }
    });
});

and splash.css file:

body {
    font: normal 1.0em Arial, sans-serif;
    background: #A8CBFF;
}

nav {
    font-size: 3.0em;
    line-height: 1.0em;
    color: white;

    width:5em;
    height: 9.0em;

    position:absolute;
    top:0; bottom:0;
    margin:auto;
    left: 0.5em;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

nav ul li {
    background-color: blue;
    height: 1.0em;
    padding: 0.15em;
    position: relative;
    border-top-right-radius: 0em;
    border-bottom-right-radius: 0em;
    -webkit-transition: -webkit-transform 200ms, background-color 200ms, color 200ms;
    transition: transform 200ms, background-color 200ms, color 200ms;
}

nav ul li:nth-child(1) { background-color: gold;}
nav ul li:nth-child(2) { background-color: gold;}
nav ul li:nth-child(3) { background-color: gold;}


nav ul li.hovered {
    background-color: black;
    -webkit-transform: translateX(2.5em);
    transform: translateX(2.5em);
}

nav ul li span {
    display:block;
    font-family: Arial;
    position: absolute;
    font-size:1em;
    line-height: 1.25em;
    height:1.0em;
    top:0; bottom:0;
    margin:auto;
    right: 0.01em;
    color: #F8F6FF;
}

a {
    color: #FFF;
    text-decoration: none;
}

/*new*/
#menuRight{
    height:800px;
    width:600px;
    overflow:hidden;
    position:relative;
    left:450px;
    top:-210px;

}
#menuRight div{
    height:100%;
}
#menuRight img{
    width:100%;
    height:auto;
}

Unfortunately, my result is not working like it should. I've received an error in the Chrome console

Uncaught ReferenceError: jQuery is not defined

Any thoughts, what's wrong?

  • 写回答

1条回答 默认 最新

  • dongling4383 2015-08-21 20:56
    关注

    To solve you error, try putting your :

    <script src="<?php echo get_template_directory_uri(); ?>/splash_assets/mynewmenu.js"></script>
    

    after the script tags to include jQuery scripts, just above </head>.

    jQuery is a jQuery variable and you're using it before it was defined.

    EDIT : (Thanks to Muntashir Akon) :

    Then, OP had this error : Uncaught TypeError: m.easing[this.easing] is not a function

    Replacing his own jQuery files by the google's ones solved OP's issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘