css单击箭头以滚动到横幅的下一部分。(代码片段)

author author     2023-01-06     423

关键词:

/**
 * Scroll to Next Section Button
 * 
 * Author: Zeshan Ahmed
 * Author URI: http://www.zeshanahmed.com/
 */
jQuery(document).ready(function($) 

  var $win = $(window),
    $arrow = $('#bottom-arrow'),
    $header = $('#header'), // Header selector
    $banner = $('.banner'); // Banner selector

  function bottomArrowPosition() 

    if ($arrow.length) 

      var headerH = $header.outerHeight(),
        bannerH = $banner.outerHeight(),
        arrowH = $arrow.outerHeight(),
        top = bannerH - arrowH - 50;

      $arrow.css('top', top);

      $arrow.off('click');
      $arrow.click(function(e) 

        e.preventDefault();

        var $this = $(this),
          $sec = $banner.next();

        if ($sec.attr('id') == 'bottom-arrow') 
          $sec = $sec.next();
        

        console.log($sec.offset().top);

        $('html, body').animate(
          scrollTop: $sec.offset().top
        , 300);

      );

    

  

  $win.ready(bottomArrowPosition).resize(bottomArrowPosition);

  $win.load(function() 

    bottomArrowPosition();
    setTimeout(function() 
      bottomArrowPosition();
    , 500);

  );

);
<a href="#" id="bottom-arrow"><span>Scroll to Next Section</span></a>
/* Additional Styling */
#bottom-arrow 
	position: absolute;
	width: 52px; /* Width of arrow image */
	height: 32px; /* Height of arrow image */
	left: 50%;
	margin-left: -26px; /* Horizontally centered, should be half of the 'width' */
	background: url(path/to/arrow/file.png) no-repeat center center;
	z-index: 10;
	text-indent: -9999px; /* To visually hide the text inside the button */


#bottom-arrow:hover 
	opacity: 0.8;

Wordpress 向下滚动箭头到页面的一部分

】Wordpress向下滚动箭头到页面的一部分【英文标题】:Wordpressscrolldownarrowtoasectionofpage【发布时间】:2018-05-1410:37:00【问题描述】:有谁知道如何在wordpress中放置一个向下滚动到页面另一部分的箭头。该箭头将位于首页标题处,... 查看详情

每天一个css(代码片段)

每天坚持一个CSS-------滚动文字效果图图片描述:箭头指向部分,以白色为背景,从左向右滚动。(不适用于IE)代码html<div>例子:<divclass="box"><spanclass="box-text">滚动的文字,我是滚动的文字</span></div></div&... 查看详情

每天一个css(代码片段)

每天坚持一个CSS-------滚动文字效果图图片描述:箭头指向部分,以白色为背景,从左向右滚动。(不适用于IE)代码html<div>例子:<divclass="box"><spanclass="box-text">滚动的文字,我是滚动的文字</span></div></div&... 查看详情

css弹跳向下滚动箭头(代码片段)

查看详情

如何在 Liferay 中单击时滚动到部分/片段?

】如何在Liferay中单击时滚动到部分/片段?【英文标题】:Howtoimplementscrolltoasection/fragmentonclickinLiferay?【发布时间】:2021-12-2121:37:45【问题描述】:我想在Liferay中实现点击时滚动到特定部分,但我不知道如何在Liferay中添加功能。... 查看详情

如何使用滚动视图单击列表部分内的项目以导航到详细信息页面 SwiftUI

】如何使用滚动视图单击列表部分内的项目以导航到详细信息页面SwiftUI【英文标题】:HowdoIclickontheitemsinsidethelistsectionwithscrollviewtonavigatetodetailpageSwiftUI【发布时间】:2019-11-0912:55:50【问题描述】:有一个列表,其中有部分,每... 查看详情

css跳跃箭头动画-setaanimação滚动(代码片段)

查看详情

如何创建一个切换箭头,当您单击箭头时“打开”一个部分以显示文本?

】如何创建一个切换箭头,当您单击箭头时“打开”一个部分以显示文本?【英文标题】:HowdoIcreateaTogglearrowthat"opensup"asectiontoshowtextasyouclickonthearrow?【发布时间】:2020-08-2310:00:09【问题描述】:TogglewhenclosedTogglewhenopened... 查看详情

滚动页面单击按钮以链接到同一页面

】滚动页面单击按钮以链接到同一页面【英文标题】:ScrollpageonClickofbuttontolinkonthesamepage【发布时间】:2016-03-0715:00:29【问题描述】:这是我的代码,它没有显示任何错误,但也不要转到href位置。当我将href更改为“www.google.com”... 查看详情

滚动页面单击按钮以链接到同一页面

】滚动页面单击按钮以链接到同一页面【英文标题】:ScrollpageonClickofbuttontolinkonthesamepage【发布时间】:2016-03-0715:00:29【问题描述】:这是我的代码,它没有显示任何错误,但也不要转到href位置。当我将href更改为“www.google.com”... 查看详情

css横幅1(代码片段)

查看详情

css横幅3(代码片段)

查看详情

css横幅6(代码片段)

查看详情

css横幅1(代码片段)

查看详情

css横幅2(代码片段)

查看详情

css横幅4(代码片段)

查看详情

css横幅7(代码片段)

查看详情

css退出横幅(代码片段)

查看详情