缩小导航栏后封面图片(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
最满意答案
一般的答案是“不要这样做”。
除此之外,您可以通过使用性能计数器获得很多收益。 如果内置计数器没有帮助,您可以创建自己的计数器。
除其他外,性能计数器可以让您了解如何通过负载测试重现性能问题。
下一个想法是缩小您感兴趣的区域。如果结果是您的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.
相关问答
更多-
如何将ASP.NET Core UserSecrets部署到生产环境(How to deploy ASP.NET Core UserSecrets to production)[2023-10-11]
不要在生产中使用应用程序秘密。 永远。 正如文章所述,在发展期间。 您如何在生产环境中发布秘密取决于您的生产环境。 Linux,Windows和Azure都支持环境变量 - 这就是你的秘密应该去的地方,使用你的托管服务提供商提供给你的任何UI。 应用程序设置文档更详细地介绍了这一点 Don't use app secrets in production. Ever. As the article says DURING DEVELOPMENT. How you publish secrets in prod ... -
ANTS Profiler非常擅长分析ASP.NET应用程序。 ANTS Profiler is very good at profiling ASP.NET applications.
-
如果您在开发工作站上运行发布版本,但有条件的编译可以执行此操作,这将无济于事 #if !DEBUG [RequireHttps] //apply to all actions in controller #endif public class SomeController { //... or ... #if !DEBUG [RequireHttps] //apply to this action only #endif public ActionResult SomeAction ...
-
WER帮助我解决了这个问题。使用WER启用了故障转储 Windows Registry Editor Version 5.00 � [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\w3wp.exe] "DumpFolder"=hex(2):63,00,3a,00,5c,00,64,00,75,00,6d,00,70,00,73,00,00,00 "DumpCount"=dword:0000 ...
-
结果如下 - 如下所示: 尽管我们已经从项目输出中删除了bin目录并重新构建 - 它没有任何效果 解决方案是清理所有的解决方案,然后重建 显然应该尝试过,但有时你的头脑不工作:) The solution as it turns out - is as follows: although we had deleted the bin directory form the project output and re-built - it had no effect solution was to clean ...
-
我在哪里可以访问生产服务器上的ASP.NET配置?(Where can I access the ASP.NET Configuration on a production server?)[2022-03-29]
这个怎么样? How about this? -
一般的答案是“不要这样做”。 除此之外,您可以通过使用性能计数器获得很多收益。 如果内置计数器没有帮助,您可以创建自己的计数器。 除其他外,性能计数器可以让您了解如何通过负载测试重现性能问题。 下一个想法是缩小您感兴趣的区域。如果结果是您的Web服务访问速度很慢,那么对整个应用程序的性能没有任何影响。 接下来,确保已经为您的应用程序进行了检测,最好是使用配置。 企业库日志记录应用程序块非常适用于此,因为它允许您将日志记录添加到应用程序,但将其配置为关闭。 然后,您可以配置要记录的信息类型以及将其记录到何处。 ...
-
无论主机选择ASP.Net核心应用程序(IIS还是通过Kestrel自行托管),在主机进程启动期间,方法Program.Main() , Startup.ConfigureServices()和Startup.Configure()执行一次。 很显然,当你用Kestrel web服务器启动exe文件时, Program.Main()被执行。 但是,在IIS中托管时实际调用它可能并不明显。 实际上是这样。 当ASP.Net核心应用程序与IIS集成时,它通常由dotnet.exe运行程序执行(它也可以配置应用程 ...
-
使用Web平台安装程序; 它专门用于帮助您准确了解运行所需的内容。 在您的情况下,它将安装完整的.NET 4.0 Framework以及您需要的其他内容,假设您使用它进行正确的选择。 安装您所说的任何组件都不会对现有应用程序做任何事情,只要您不会错误地配置它们,以致不正确地尝试使用新的框架。 所有这些东西默认都是并行工作的。 Use the Web Platform Installer; it's specifically meant to help you get exactly what you nee ...
-
基于MVC第1版,在最终版本发布之前有很多预览。 最初的ASP.NET MVC 1 Preview 1与最终版本截然不同。 最终的MVC 1预览版5与最终版本非常相似,差别很小(如果有的话),我认为主要区别是错误修复。 虽然MVC 2是对MVC 1的改进,但它确实有一些主要的新举措(例如区域),并且无法保证当前MVC 2预览1的工作方式是最终产品的工作方式。 如果您需要在生产系统中使用寿命,我建议您不要在生产环境中使用任何预览产品,除非您愿意处理最终版本中可能发生的重大变化。 附注...如果您使用连续预览版 ...