缩小导航栏后封面图片(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)
ASP.Net工作进程内存配置文件工具(ASP.Net Worker Process Memory Profile Tools)
ASP.NET MVC RequireHttps仅在生产中(ASP.NET MVC RequireHttps in Production Only)
在生产中运行的asp.net应用程序正在崩溃(asp.net application running in production is crashing)
无法加载文件或程序集 - 处理本地而不是生产 - ASP.net(Could not load file or assembly - working on local not on production - ASP.net)
我在哪里可以访问生产服务器上的ASP.NET配置?(Where can I access the ASP.NET Configuration on a production server?)
您如何描述生产ASP.NET应用程序?(How do you profile a production ASP.NET applicaiton?)
在生产中实例化ASP.NET Core应用程序(Instantiation of ASP.NET Core application in production)
将生产服务器从ASP.NET 2升级到ASP.NET 4(Upgrade production server from ASP.NET 2 to ASP.NET 4)
在生产应用程序中使用ASP.NET MVC 2 Preview 1是否可行?(Is it viable to use ASP.NET MVC 2 Preview 1 in a production application?)
相关文章
更多C#中Image.FromFile()的用法
微信公众平台开发(91) 右上角按钮/底部导航栏/用户网络状态
jquery滚动图片导航与图片放大效果模板
加载图片时,相同的路径名,用不同的方法时结果却不一样?
Java添加图片水印
微信点击超链接第一次不会有“微信中网页底部导航栏”,进入之后再点击链接就会有了,自己会新建窗口
如何在jsp中显示数据库的图片
几款开源图片剪切插件
【原创】小白学jquery Mobile《构建跨平台APP:jQuery Mobile移动应用实战》连载五(给按钮加图标)
图片篇-高性能WEB开发
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!