首页 \ 问答 \ 缩小导航栏后封面图片(Shrink navbar AFTER cover image)

缩小导航栏后封面图片(Shrink navbar AFTER cover image)

我正在使用Bootstrap 4从头开始构建一个网站。我们的想法是在顶部有一个带有“固定到位”透明导航栏的全屏封面图像; 这部分很容易,我可以闭着眼睛做很多事情。 我现在试图实现的效果是,当用户向下滚动并打开封面图片的末尾时,导航栏将缩小并粘在顶部。

我发现很多教程和指南都教导了如何在Jquery中实现这一点,但是他们都提供了基本上使代码在'如此多像素'之后缩小的代码(在50以下的例子中)。 我喜欢Jquery在类中添加然后删除类的想法,但是我不确定如何修改它以便在它到达我的封面图像的底部而不是50px时激活。

$(window).scroll(function() {
  if ($(document).scrollTop() > 50) {
    $('nav').addClass('shrink');
  } else {
    $('nav').removeClass('shrink');
  }
});

I'm building a website from scratch using Bootstrap 4. The idea is to have a full screen cover image with a 'fixed in place' transparent navbar at the top; this part is easy and I can pretty much do it with my eyes closed. What I'm trying to now achieve is an effect so when the user scrolls down and hits the end of the cover image, the navbar will shrink down and be sticky at the top.

I've found so many tutorials and guides that teach how to do this in Jquery however they all offer basically the code which is to make it shrink after 'so many pixels' (in the case of the example below its 50). I like the idea of the Jquery adding in a class and then removing the class, however I'm not sure how I can modify so it activates when it hits the bottom of my cover image rather than the 50px.

$(window).scroll(function() {
  if ($(document).scrollTop() > 50) {
    $('nav').addClass('shrink');
  } else {
    $('nav').removeClass('shrink');
  }
});

原文:https://stackoverflow.com/questions/47380079
更新时间:2022-11-12 19:11

最满意答案

一般的答案是“不要这样做”。

除此之外,您可以通过使用性能计数器获得很多收益。 如果内置计数器没有帮助,您可以创建自己的计数器。

除其他外,性能计数器可以让您了解如何通过负载测试重现性能问题。

下一个想法是缩小您感兴趣的区域。如果结果是您的Web服务访问速度很慢,那么对整个应用程序的性能没有任何影响。

接下来,确保已经为您的应用程序进行了检测,最好是使用配置。 企业库日志记录应用程序块非常适用于此,因为它允许您将日志记录添加到应用程序,但将其配置为关闭。 然后,您可以配置要记录的信息类型以及将其记录到何处。

这使您可以选择日志记录的成本,从记录到事件日志到记录到XML文件。 你可以在运行时决定这一切。

最后,您将无法使用dotTrace或其他需要重新启动IIS以及向正在运行的应用程序添加代码的内容。 不在生产中。 上述想法是为了不需要这样做。


The general answer is "don't do it".

Other than that, you can gain a lot by using performance counters. If the built-in counters don't help, you can create your own.

Among other things, the performance counters may give you an idea of how to reproduce the performance problems through load testing.

The next idea is to narrow down the area you're interested in. There's no sense impacting performance for the entire application if it turns out to be your web service access that's slow.

Next, be sure to have instrumented your application, preferably by using configuration. The Enterprise Library Logging Application Block is great for that, as it allows you to add the logging to your application, but have it configured off. Then, you can configure what kind of information to log, and where to log it to.

This gives you choices about how expensive the logging should be, from logging to the event log to logging to an XML file. And you can decided this all at runtime.

Finally, you're not going to be able to use dotTrace or something else that requires restarting IIS an adding code to your running application. Not in production. The ideas above are for the purpose of not needing to do so.

相关问答

更多

相关文章

更多

最新问答

更多
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • Java中的不可变类(Immutable class in Java)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • EXCEL VBA 基础教程下载
  • RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
  • 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)
  • JAVA环境变量的设置和对path , classpth ,java_home设置作用和目的?
  • mysql 关于分组查询、时间条件查询
  • 如何使用PowerShell匹配运算符(How to use the PowerShell match operator)
  • Effective C ++,第三版:重载const函数(Effective C++, Third edition: Overloading const function)
  • 如何用DELPHI动态建立MYSQL的数据库和表? 请示出源代码。谢谢!
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 使用前端框架带来哪些好处,相对于使用jquery
  • Ruby将字符串($ 100.99)转换为float或BigDecimal(Ruby convert string ($100.99) to float or BigDecimal)
  • 高考完可以去做些什么?注意什么?
  • 如何声明放在main之后的类模板?(How do I declare a class template that is placed after the main?)
  • 如何使用XSLT基于兄弟姐妹对元素进行分组(How to group elements based on their siblings using XSLT)
  • 在wordpress中的所有页面的标志(Logo in all pages in wordpress)
  • R:使用rollapply对列组进行求和的问题(R: Problems using rollapply to sum groups of columns)
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • python中使用sys模块中sys.exit()好像不能退出?
  • 将Int拆分为3个字节并返回C语言(Splitting an Int to 3 bytes and back in C)
  • 在SD / MMC中启用DDR会导致问题吗?(Enabling DDR in SD/MMC causes problems? CMD 11 gives a response but the voltage switch wont complete)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 如何将字符串转换为Elixir中的函数(how to convert a string to a function in Elixir)