一度は見かけたことがあると思う、スクロールしたらヘッダーやナビゲーションを固定表示させたり見栄えを変化させたりする動きをjQueryで実装するサンプルです。 途中から要素を固定させたり、スクロールした方向によって表示・非表示を切り替えたりなど全5種類です。 使用HTML 特にこのようにしなければいけないというものではないですが、今回のサンプルで使用しているHTMLはいずれも下記のようなもの(サンプルによってはnav要素がないものもあります)になっており、このHTMLにあるheaderやnav要素に対してjQueryで処理していくといった感じになります。 <header> ...</header> <nav> ... </nav> <main> ... </main> <footer> ... </footer>
JavaScriptで外部ファイルの読み込みを遅延させる PageSpeed Insightsでサイトの速度チェックをすると、次のような提案が出てくることがあります。 スクロールせずに見えるコンテンツのレンダリングをブロックしている JavaScript/CSS を排除する これは、headで読み込んだJavaScriptやCSSのファイルがコンテンツの表示を遅らせているためです。 ファーストビューに影響が出ないCSSは、コンテンツの描画後に読み込ませた方が良いでしょう。 ということで、外部CSSを読み込むタイミングを遅らせて、コンテンツの表示を速くしました。 当サイトではメインのCSSをインライン化しているのですが、外部ファイルも読み込んでいます。 使っているのは、Google FontsとFont AwesomeのCSSです。 導入方法 あらかじめGoogle FontsとFont A
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く