css 可能是 jquery 帮助

发布于 2024-10-31 09:52:36 字数 229 浏览 7 评论 0原文

我的设计师设计了以下导航

navigation bar

他希望实现它,以便导航下方的暗栏动画到当前页面加载页面(想想进度条)。对于 PHP 来说没有明显的问题,我可以对其进行排序,以便当前的 a 有一个类,这样我就可以识别当前页面,但是我不知道如何为导航下方的栏设置动画,有人有吗建议?

My designer has designed the following navigation

navigation bar

He is wanting it implmented so that the dark bar underneath the nav animates to the current page on page load (think progress bar). No obvioulsy with PHP I can sort it so that the current a has a class so I can identify the current page, however I have no idea how I could animate the bar underneath the nav, does anyone have any advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

世俗缘 2024-11-07 09:52:36

抱歉,我会在这里发帖。

我认为你需要一个 div 内的 div 。外部 div(代表导航下方的整行)需要是整个导航的宽度。然后,您可以使用 jquery 将内部 div(进度条)设置为与上面的 nav 元素相同的宽度,并将其左侧位置设置为您已添加类的导航项的位置。

类似的东西

$(document).ready(function(){

    $('.selectedNav').click(function(){

    var navWidth = $(this).width();
    var posLeft = $(this).position();

    $('#innerDiv').animate({'width': navWidth, 'left': posLeft.left});

    });

});

Sorry I'll post in here instead.

I think you would need a div within a div. The outer div (representing the full line underneath your navigation) would need to be the width of the total navigation. You could then use jquery to animate the inner div (progress bar) to the same width as the nav element above and animate its left position to that of the navigation item you have added the class to.

Something Like

$(document).ready(function(){

    $('.selectedNav').click(function(){

    var navWidth = $(this).width();
    var posLeft = $(this).position();

    $('#innerDiv').animate({'width': navWidth, 'left': posLeft.left});

    });

});
亚希 2024-11-07 09:52:36
  • 制作一个绿色框的图像,其中包含文本和栏“剪切”(例如透明),
  • 将其放入
  • 中,放置另一个 div一:
  • 将“进度”div 的宽度设置为第 1 步的 90 像素、第 2 步的 195 像素、第 3 步的 278 像素、第 4 步的 414 像素
  • 如果需要,请使用 jQuery 动画进行设置: $.animate({width: 195}) 使其滚动。

执行此操作,您的栏和文本都会移动。

如果您不关心文本,请跳过图像部分,只需制作一个灰色 div 来执行相同的操作。

有关动画效果,请参见 www.vouchr.com。

  • Make an image that is your green box with the text and bar "cut out" (e.g. transparent)
  • place that into a <div style="position:relative;">
  • place another div in that one: <div style="position:absolute;top:0px;left:0px;height:100%;" id="progress">
  • Set the width of your "progress" div to 90px for step 1, 195px for step 2, 278px for step 3, 414px for step 4
  • If you want, set the with using jQuery's animation: $.animate({width: 195}) to get it to scroll.

Do this and both your bar and text will move.

If you don't care about the text, skip the image part and just make a grey div that does the same thing.

See www.vouchr.com for the animation effect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文