如何在 HTML 文本输入字段周围添加类似 Twitter 的淡入效果?

发布于 2024-09-17 23:27:11 字数 78 浏览 5 评论 0原文

我知道输入字段周围的发光是标准的,但 Twitter 设法让它顺利淡出。我一直在环顾四周,但似乎找不到实现这一目标的可靠方法。这是怎么做到的?

I know a glow around input fields is standard, but Twitter manages to fade it in smoothly. I've been looking around but can't seem to find a solid way to achieve this. How is this done?

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

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

发布评论

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

评论(1

戏蝶舞 2024-09-24 23:27:12

twitter 是这样实现的:

HTML:

  <p class="search-holder" style="opacity: 0.6;">
    <label for="searchform_q">Search for a keyword or phrase…</label>
    <input type="text" tabindex="8" size="30" name="q" id="searchform_q" class="round-left" accesskey="/"><input type="submit" value="Search" tabindex="9" name="commit" id="searchform_submit" class="submit round-right">
  </p>

jQuery:

  $('.search-holder').mouseenter(function(){
        $(this).animate({opacity:1});
  }).mouseleave(function(){
        $(this).animate({opacity:0.6});
  });

Here's how twitter does it:

HTML:

  <p class="search-holder" style="opacity: 0.6;">
    <label for="searchform_q">Search for a keyword or phrase…</label>
    <input type="text" tabindex="8" size="30" name="q" id="searchform_q" class="round-left" accesskey="/"><input type="submit" value="Search" tabindex="9" name="commit" id="searchform_submit" class="submit round-right">
  </p>

jQuery:

  $('.search-holder').mouseenter(function(){
        $(this).animate({opacity:1});
  }).mouseleave(function(){
        $(this).animate({opacity:0.6});
  });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文