現在、紙芝居風のパララックスでのページにアンカーリンクをつけようとしています。
紙芝居風のパララックスの参考サイト
https://www.webprofessional.jp/js-library-scrollreveal-2/
上記のデモ1
紙芝居風のパララックスをつくる為の性質上、z-indexの小さい物の上にどんどんと要素が重なるため、
ページ内リンクも、下に進む動きはできますが、上に上がる動き
(紙芝居を、めくる?重なった要素を剥がすような動き?)
をどうすれば解決できるか分からず止まっております。
このような感じで実装しているサイトも特になく、
分かるかたがいましたらご教示ください。
全部のコードを乗せると、長くなるため、抜粋しております。
具体的にを文面で伝えると、難しいため、
https://xs442579.xsrv.jp/test/recruit/
テスト環境にアップしております。
右上のページ内リンクを押すと、下にスクロールはできるが、上には、戻れない?感じです。
いやいや、position: sticky; を使用しているからだろ!
に関しましては、事前に概要に書いておりますので、その点はを踏まえて、見てくださませ。
HTML
1 2``` <ul class="toc"> 3 <li class="toc__item"> 4 <a class="toc__link" href="#split00"> 5 <img src="<?php echo esc_url(get_theme_file_uri('img/recruit/icon_home.svg')); ?>" alt="HOME"> 6 </a> 7 </li> 8 <li class="toc__item"> 9 <a class="toc__link" href="#split01">01</a> 10 </li> 11 <li class="toc__item"> 12 <a class="toc__link" href="#split02">02</a> 13 </li> 14 <li class="toc__item"> 15 <a class="toc__link" href="#split03">03</a> 16 </li> 17 <li class="toc__item"> 18 <a class="toc__link" href="#split04">04</a> 19 </li> 20 <li class="toc__item"> 21 <a class="toc__link" href="#split05">05</a> 22 </li> 23 </ul> 24 25 <!-- <div class="prev"> 26 <img src="<?php echo esc_url(get_theme_file_uri('img/recruit/icon_prev.svg')); ?>" alt=""> 27 </div> 28 29 <div class="next"> 30 <img src="<?php echo esc_url(get_theme_file_uri('img/recruit/icon_next.svg')); ?>" alt="HOME"> 31 </div> --> 32 33<div id="luxy" class="split"> 34 35 <!-- <div id="split01" class="block block-one"> 36 <p class="block__text">One</p> 37 </div> 38 <div id="split02" class="block block-two"> 39 <p class="block__text">Two</p> 40 </div> 41 <div id="split03" class="block block-three"> 42 <p class="block__text">Three</p> 43 </div> 44 <div id="split04" class="block block-four"> 45 <p class="block__text">Four</p> 46 </div> 47 <div id="split05" class="block block-five"> 48 <p class="block__text">Five</p> 49 </div> --> 50 51 52 <div id="split00" class="block block-home"> 53 <p class="block__text">Home</p> 54 </div> 55 <div id="split01" class="block block-one"> 56 <p class="block__text">One</p> 57 </div> 58 <div id="split02" class="block block-two"> 59 <p class="block__text">Two</p> 60 </div> 61 <div id="split03" class="block block-three"> 62 <p class="block__text">Three</p> 63 </div> 64 <div id="split04" class="block block-four"> 65 <p class="block__text">Four</p> 66 </div> 67 <div id="split05" class="block block-five"> 68 <p class="block__text">Five</p> 69 </div> 70</div> 71 72 73 74 75 76 77 78 79 80 81 82```CSS 83.toc { 84 position: fixed; 85 top: 30px; 86 right: 30px; 87 z-index: 100; 88 display: flex; 89} 90 91.toc__item { 92 display: flex; 93 width: 30px; 94 height: 30px; 95 border: 1px solid #707070; 96 border-radius: 50%; 97 background: #fff; 98} 99 100.toc__item:not(:first-child) { 101 font-weight: 700; 102} 103 104.toc__item:not(:last-child) { 105 margin-right: 20px; 106} 107 108.toc__link { 109 display: flex; 110 justify-content: center; 111 align-items: center; 112 width: 100%; 113 color: #30386C; 114 /*width: 30px;*/ 115} 116 117.toc__item:first-child .toc__link img { 118 width: 14px; 119} 120 121.prev, 122.next { 123 position: fixed; 124 left: 50%; 125 transform: translateX(-50%); 126 z-index: 100; 127 width: 40px; 128} 129 130.prev { 131 top: 30px; 132} 133 134.next { 135 bottom: 30px; 136} 137 138 139 140 141.block { 142 /* スクロールスナップ */ 143 /*scroll-snap-align: start;*/ 144 height: 100vh; 145 146 147 display: flex; 148 justify-content: center; 149 align-items: center; 150 width: 100%; 151 position: -webkit-sticky; 152 position: sticky; 153 top: 0; 154 left: 0; 155} 156 157.block-home { 158 background: #f6bfbc; 159} 160 161.block-one { 162 background: #212E32; 163 color: #fff; 164 z-index: 10; 165} 166 167.block-two { 168 background: #85937A; 169 z-index: 20; 170} 171 172.block-three { 173 background: #d0af4c; 174 z-index: 30; 175} 176 177.block-four { 178 background: #4c6473; 179 z-index: 40; 180} 181 182.block-five { 183 background: #c37854; 184 z-index: 50; 185} 186 187.block__text { 188 font-size: 60px; 189 font-family: 'Great Vibes', cursive; 190}``` 191 192 193 194```jQuery 195$(function(){ 196 197 /*================================================= 198 スムーススクロール 199 =================================================*/ 200 $('a[href^="#"]').click(function(){ 201 let href= $(this).attr("href"); 202 let target = $(href == "#" || href == "" ? 'html' : href); 203 let position = target.offset().top; 204 $("html, body").animate({scrollTop:position}, 500, "swing"); 205 return false; 206 }); 207 208});




回答1件
あなたの回答
tips
プレビュー