0

さて、これはすべてのブラウザと解像度に当てはまるようです。私はコーディングにまったく慣れていないので、それは私が見逃している単純なエラーであるとかなり確信しています。私は友人のグループに尋ねました、そしてそれは誰にとっても同じようです。ナビゲーションホバーは、メインのコード化されたレイアウト(まだ完全にコード化されていない)でのみ機能する場合があります。ナビゲーションを単独で引き出しましたが、100%正常に動作しているようです。

ここでどのように機能するかを確認できます:http://dperolio.com/newnav/css/

ここに問題があります:http://dperolio.com/tealtop2

最初はうまくいくかもしれませんし、うまくいかないかもしれません。スパム更新(Ctrl + R)を行うと、機能する場合があります。動作しないときは、何があってもホバー状態になっているようです(太字の白いリンク)。

私はあなたが提供できるどんな洞察にも感謝します。繰り返しになりますが、私は愚かな間違いを犯したと確信しています。うまくいけば、より経験豊富な誰かがそれを見つけて指摘してくれるでしょうか。ありがとう!

4

2 に答える 2

0

これが私があなたのために作った簡単なデモです:

$(document).ready(function() {

  $("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

  $("#topnav li").each(function() { //For each list item...
    var linkText = $(this).find("a").html(); //Find the text inside of the a tag
    $(this).find("span").show().html(linkText); //Add the text in the span tag
  });

  $("#topnav li").hover(function() { //On hover...
    $(this).find("span").stop().animate({
      marginTop: "-40" //Find the span tag and move it up 40 pixels
    }, 250);
  }, function() { //On hover out...
    $(this).find("span").stop().animate({
      marginTop: "0" //Move the span back to its original state (0px)
    }, 250);
  });

});
ul#topnav {
  margin: 0;
  padding: 0;
  list-style: none;
  float: left;
  font-size: 1.1em;
}

ul#topnav li {
  margin: 0;
  padding: 0;
  overflow: hidden;
  /*--Important - Masking out the hover state by default--*/
  float: left;
  height: 40px;
}

ul#topnav a,
ul#topnav span {
  /*--The <a> and <span> share the same properties since the <span>  will be a duplicate of the <a> tag--*/
  padding: 10px 20px;
  float: left;
  text-decoration: none;
  color: #000;
  background: url(a_bg.gif) repeat-x;
  text-transform: uppercase;
  clear: both;
  width: 100%;
  height: 20px;
  line-height: 20px;
  /*--Vertical alignment of text--*/
}

ul#topnav a {
  /*--This is basically the hover state of navigation--*/
  color: #555;
  background-position: left bottom;
}

ul#topnav span {
  /*--Default state of navigation--*/
  background-position: left top;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
  <ul id="topnav" class="v2">
    <li><a href="http://www.sohtanaka.com/">Home</a></li>
    <li><a href="http://www.sohtanaka.com/web-design/web-design-services.php">Services</a></li>
    <li><a href="http://www.sohtanaka.com/web-design/designbombscom/">Portfolio</a></li>
    <li><a href="http://www.sohtanaka.com/web-design-blog/">Blog</a></li>
    <li><a href="http://www.sohtanaka.com/about/">About</a></li>
  </ul>
</div>

于 2011-10-15T19:48:37.220 に答える
0

私はそれが愚かなことだと知っていました...それは、jQueryを呼び出す前ではなく、呼び出した後に外部CSSをリストしたためです。

于 2011-11-06T12:04:06.487 に答える