Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
3年前关闭。
我已经在该网站上工作了一段时间,但遇到了一个我最近才注意到的问题。如果您运行下面的代码,您将找到一个可单击的滚动箭头,将您带到下一部分。但是,单击后,该部分将立即传输。我希望能够单击它,并且我可以顺利向下滚动。之前,我是无意中做到了这一点,但我一直无法弄清楚自己做了什么。如果有人能告诉我怎么做,我将不胜感激。
谢谢,
约翰
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
3年前关闭。
我已经在该网站上工作了一段时间,但遇到了一个我最近才注意到的问题。如果您运行下面的代码,您将找到一个可单击的滚动箭头,将您带到下一部分。但是,单击后,该部分将立即传输。我希望能够单击它,并且我可以顺利向下滚动。之前,我是无意中做到了这一点,但我一直无法弄清楚自己做了什么。如果有人能告诉我怎么做,我将不胜感激。
谢谢,
约翰
#section01 {
background: url(http://wallpapercave.com/wp/LekAYO3.jpg) center center / cover no-repeat;
}
#section02 {
background: url(http://wallpapercave.com/wp/8iAP1eI.jpg) center center / cover no-repeat;
}
.arrow a {
position: absolute;
bottom: 50px;
left: 50%;
z-index: 8;
display: inline-block;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
color: #fff;
font: normal 400 20px/1'Josefin Sans', sans-serif;
font-weight: bold;
letter-spacing: .1em;
text-decoration: none;
transition: opacity .3s;
}
/*
.arrow a:hover {
opacity: .5;
}
*/
#section01 a,
#section02 a,
#section03 a,
#section03 a,
#section04 a,
#section05 a,
#section06 a {
padding-top: 60px;
}
/* WHITE ARROW */
#section01 a span,
#section04 a span,
#section05 a span,
#section06 a span {
position: absolute;
top: 0;
left: 50%;
width: 24px;
height: 24px;
margin-left: -12px;
border-left: 1px solid #fff;
border-bottom: 1px solid #fff;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-animation: sdb01 2s infinite;
animation: sdb01 2s infinite;
box-sizing: border-box;
}
/* BLACK ARROW */
#section02 a span,
#section03 a span,
#section03 a span {
position: absolute;
top: 0;
left: 50%;
width: 24px;
height: 24px;
margin-left: -12px;
border-left: 1px solid black;
border-bottom: 1px solid black;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-animation: sdb01 2s infinite;
animation: sdb01 2s infinite;
box-sizing: border-box;
}
@-webkit-keyframes sdb01 {
0% {
-webkit-transform: rotate(-45deg) translate(0, 0);
}
20% {
-webkit-transform: rotate(-45deg) translate(-10px, 10px);
}
40% {
-webkit-transform: rotate(-45deg) translate(0, 0);
}
}
@keyframes sdb01 {
0% {
transform: rotate(-45deg) translate(0, 0);
}
20% {
transform: rotate(-45deg) translate(-10px, 10px);
}
40% {
transform: rotate(-45deg) translate(0, 0);
}
}
<section id="section01" class="arrow" style="background-attachment: fixed;">
<h1 class="main">Welcome</h1>
<h5 class="main"> <br> <br> <br> <br> A Website by John Ta </h5>
<a href="#section02"><span></span>Scroll</a>
</section>
<!-- END SECTION01 -->
<section id="section02" class="arrow" style="background-attachment: fixed;">
<h3 class="main" style="color: black;
">Filler?</h3>
<h5 class="main" style="color: black;"> <br> <br> <br> <br> Filler</h5>
<a href="#section03" style="color: black;"><span></span>Scroll</a>
</section>
<!-- END SECTION02 -->
最佳答案
在#anchors
之间跳转是由浏览器本身处理的,而不是CSS转换,因此,除非您要寻找一种涉及容器元素和绝对定位的创造性(且可能有些混乱)的解决方法,否则影响浏览器滚动的唯一方法是使用JavaScript。
您可以使用一些现有的库,例如Chris Ferdinandi的smooth-scroll,也可以尝试使用一些help编写自己的库。