質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
jQueryプラグイン

jQueryの拡張機能。 様々な種類があり、その数は膨大です。公開済みのプラグインの他にも、自作することもできます。 jQueryで利用できるようにしておくだけで、導入およびカスタマイズが比較的容易に行なえます。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

jQuery

jQueryは、JavaScriptライブラリのひとつです。 簡単な記述で、JavaScriptコードを実行できるように設計されています。 2006年1月に、ジョン・レシグが発表しました。 jQueryは独特の記述法を用いており、機能のほとんどは「$関数」や「jQueryオブジェクト」のメソッドとして定義されています。

Q&A

0回答

1385閲覧

Slidebarsを使って、ページ内リンクが飛ばない

Leon-Lionking

総合スコア37

jQueryプラグイン

jQueryの拡張機能。 様々な種類があり、その数は膨大です。公開済みのプラグインの他にも、自作することもできます。 jQueryで利用できるようにしておくだけで、導入およびカスタマイズが比較的容易に行なえます。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

jQuery

jQueryは、JavaScriptライブラリのひとつです。 簡単な記述で、JavaScriptコードを実行できるように設計されています。 2006年1月に、ジョン・レシグが発表しました。 jQueryは独特の記述法を用いており、機能のほとんどは「$関数」や「jQueryオブジェクト」のメソッドとして定義されています。

0グッド

0クリップ

投稿2018/02/02 06:23

jQuery Slidebars
上記のプラグインを使っておりますが、
メニューをクリックしたところ、ページ内リンクに飛ばなくなりました。

問題点
・スムーススクロールを使っていますが、ほかの部分ではちゃんと動作できています。
・jQuery Slidebars を使って、ページ内リンクをしていますが、きれいにスムーススクロールを使ってページ内リンクを飛びたい。

HTML

<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>デモサイト</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="format-detection" content="telephone=no"> <meta name="description" content="" /> <meta name="keywords" content="" /> <!-- Favicon # --> <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon"> <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon"> </head> <body> <!-- Menu Button # --> <button class="js-toggle-right-slidebar">Menu</button> <div canvas="container"> <header role="banner"> <h1>サイトの名前</h1> <h2>サイトの要約</h2> </header><!-- # Header --> <main role="main"> <heade> <h1>ページ内のタイトル</h1> </header> <article> <section id="page01" name="page01"> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> </section> <section id="page02" name="page02"> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> </section> <section id="page03" name="page03"> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> </section> <section id="page04" name="page04"> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> <p>sample textsample textsample textsample textsample textsample textsample text sample text</p> </section> </article> </main> <footer> <small id="copy">Copyright(c) demosite all rights reserved.</small> </footer> </div> <nav id="slidebar" role="navigation" off-canvas="slidebar-2 right shift"> <ul> <li><a href="#page01">Page 01</a></li> <li><a href="#page02">Page 02</a></li> <li><a href="#page03">Page 03</a></li> <li><a href="#page04">Page 04</a></li> </ul> <button class="nav_close js-close-right-slidebar">Close</button> </nav> <link rel="stylesheet" type="text/css" href="./slidebars.css" media="all"> <!-- Script # --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <!-- Slider Menu # --> <script src="./slidebars.js"></script> <script src="./scripts.js"></script> <!-- Smooth Scroll # --> <script type="text/javascript"> $(function(){ var headerHight = 0; //ヘッダの高さ // #で始まるアンカーをクリックした場合に処理 $('a[href^=#]').click(function() { // スクロールの速度 var speed = 500; // ミリ秒 // アンカーの値取得 var href= $(this).attr("href"); // 移動先を取得 var target = $(href == "#" || href == "" ? 'html' : href); // 移動先を数値で取得 //var position = target.offset().top; var position = target.offset().top-headerHight; //ヘッダの高さ分位置をずらす // スムーススクロール $('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); }); </body> </html>

ご教授お願いいたします。

以上

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問