谷歌的无图像按钮

发布于 2024-07-13 10:44:49 字数 1304 浏览 7 评论 0 原文

最近有一些关于 Google 新的无图像按钮的文章:

我真的很喜欢这些新按钮在 Gmail 中的工作方式。 如何在我的网站上使用这些或类似的按钮? 是否有任何具有类似外观和功能的开源项目? 感觉?

如果我想使用 JQuery/XHTML/CSS 滚动我自己的按钮包,我可以使用哪些元素? 我最初的想法是:

  1. 标准 使用 css 来改善外观(设计文章主要讨论了涉及到的 css/imges。)

  2. Jquery javascript 来调出一个基于 root 的自定义对话框到“onclick”事件上的按钮,其中包含 标签和用于过滤的搜索栏? 该弹出窗口的表格布局是否合理?

我不擅长对网络上的东西进行逆向工程,我可以使用哪些工具来帮助对这些按钮进行逆向工程? 使用 Firefox 的 Web 开发人员工具栏,我无法真正看到按钮弹出对话框中使用的 css 或 javascript(即使已缩小)。 我可以使用什么浏览器工具或其他方法来查看它们并获得一些想法?

我不想窃取任何 Google 的 IP,只是了解如何创建类似的按钮功能。

There have been a few articles recently about Google's new imageless buttons:

I really like how these new buttons work in Gmail. How can I use these or similar buttons on my site? Are there any open source projects with a similar look & feel?

If I wanted to roll my own button package like this using JQuery/XHTML/CSS, what elements could I use? My initial thoughts are:

  1. Standard <input type="button"> with css to improve the look (the design article talked mostly about the css/imges involves.)

  2. Jquery javascript to bring up a custom dialog rooted to the button on the "onclick" event which would have <a> tags in them and a search bar for filtering? Would a table layout for that popup be sane?

I'm terrible at reverse engineering things on the web, what are some of the tools that I could use to help reverse engineer these buttons? Using Firefox's web developer toolbar I can't really see the css or javascript (even if it is minified) that is used on the buttons popup dialogs. What browser tool or other method could I use to peek at them and get some ideas?

I'm not looking to steal any of Google's IP, just get an idea of how I could create similar button functionality.

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

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

发布评论

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

评论(11

够钟 2024-07-20 10:44:57

带有关闭库链接的帖子不适用。 作为闭包库的一部分发布的内容使用带有渐变的按钮。

列出的其他解决方案没有用。 您无法从那里开始让这些按钮在 Gmail 允许的每个浏览器上正常工作。 鲍曼在他的网站上显示的不是工作代码。

The post with a link to the closure library does not apply. What was released as part of the closure library uses buttons with gradients.

The other solutions listed are useless. You cannot go from there and get these buttons working on every browser Gmail has them working. What Bowman shows on his site is not working code.

罪#恶を代价 2024-07-20 10:44:56

Web 开发者工具栏 在 css 菜单下有一个视图样式信息,会告诉你什么CSS应用到了一个项目。 该菜单中还有“编辑 CSS”功能,可让您动态更改 CSS 以查看它如何影响页面。

The Web Developer Toolbar has a view style information under the css menu that will tell you what css is applied to an item. There is also the Edit CSS feature in that menu that will let you change the CSS on the fly to see how it affects the page.

狼亦尘 2024-07-20 10:44:55

这里的大部分工作可能不是设计 - 这些帖子已经是关于渐变效果的出色指南。

问题是让这个在所有浏览器中工作,或者更具体地说是 IE6 和 IE7 等奇怪的垃圾堆。

我认为您走在正确的轨道上,使用一个用 jQuery 重写的标准按钮 - 这样屏幕阅读器仍然可以访问您的内容,并且可以在真正旧的浏览器中很好地降级。

对于 HTML,我认为你最好的选择是使用每个浏览器访问 Gmail 并查看生成的 HTML - 我希望 IE6、IE7(也取决于它们是否需要怪异模式)和其他所有浏览器生成的 HTML 完全不同。

The majority of the work here probably won't be the design - those posts are already an excellent How-To on the gradient effects.

The problem is getting this working in all browsers, or more specifically the quirky piles of rubbish that are IE6 and IE7.

I think you're on the right track with a standard button that gets re-written with jQuery - that way you'll still be accessible for screen readers and can degrade nicely in really old browsers.

For the HTML I think your best bet is to visit Gmail with each browser and see what HTML is produced - I'd expect it to be completely different for IE6, IE7, (also depending on whether they need quirks-mode) and everything else.

勿忘心安 2024-07-20 10:44:55

这些是作为闭包库的一部分发布的:请参阅按钮演示

These were released as part of the closure library: see the button demo

狼性发作 2024-07-20 10:44:54

2011 年更新此帖子:

Google 于 2011 年 7 月在其服务中推出了新设计。新的 Google 按钮已在此处重新创建:http://pixify.com/blog/use-google-plus-to-improve-your-ui/

新按钮如下所示:
在此处输入图像描述

Updating this post for 2011:

Google launched a new design across its services in July 2011. The new Google buttons have been recreated here: http://pixify.com/blog/use-google-plus-to-improve-your-ui/

The new buttons look like this:
enter image description here

演多会厌 2024-07-20 10:44:54

您可以尝试使用 Firefox 的 Firebug 插件来查看按钮上的 CSS。

You could try using the Firebug plugin for Firefox to view the CSS on the button.

沦落红尘 2024-07-20 10:44:54

您将遇到的最大问题是使其能够跨浏览器工作。

我认为你应该认真考虑你是否真的需要它......谷歌通过制作这样的东西获得了很大的回报,因为他们需要大量的按钮和语言; 我怀疑大多数网站和应用程序都可以使用图像。

不过,开源组件是一个好主意:广泛传播财富和努力。

The biggest problem you are going to have will be making it work across browsers.

I think you should strongly consider whether you really need it ... Google gets a lot of bang for the buck by making something like this because of the vast number of buttons and languages that they need; I suspect that most sites and applications would be just as well-off using an image.

An open-source component is a good idea, though: spread the wealth and effort widely.

那些过往 2024-07-20 10:44:53

无论您决定如何执行,请确保首先使用默认值渲染页面:

<input type="submit" value="submit" />

... 然后使用 jQuery 将输入元素与具有 onClick 事件的自定义按钮交换。 这将确保未启用 JavaScript 的用户仍然能够使用您的网站。

可用性应该是第一位的!

However you decide to do it, make sure you first render the page with the default:

<input type="submit" value="submit" />

... And then use jQuery to swap the input element with your custom button that has an onClick event. This will ensure that people without JavaScript enabled will still be able to use your site.

Usability should come first!

画离情绘悲伤 2024-07-20 10:44:53

你可以使用我开发的这个 jquery 插件。 这些按钮几乎可以在任何地方使用,而且由于它是一个插件,因此很容易设置和配置。

http://swizec.com/code/styledButton/

You could use this jquery plugin I've developed. The buttons work pratically anywhere and since it's a plugin they're easy to set up and configure.

http://swizec.com/code/styledButton/

空宴 2024-07-20 10:44:52

- 编辑 - 我没有看到原始帖子中的链接。 对不起! 将尝试重写以反映实际问题

StopDesign 有一篇关于此的精彩帖子 这里[edit 20091107] 这些是作为闭包库的一部分发布的:请参阅按钮演示

基本上是自定义的他显示的按钮是使用简单的CSS创建的。

他最初使用了 9 个表格来达到效果: 9 Tables

但后来他用了一个简单的上下边框各留1px左右边距,可以达到同样的效果。

渐变是通过使用三层来伪造的: Button Gradient

所有代码都可以找到在自定义按钮 3.1 页面。 (虽然没有图像的渐变仅适用于 Firefox 和 Safari)

分步说明

1 - 插入以下 CSS:

/* Start custom button CSS here
---------------------------------------- */
.btn {
  display:inline-block;
  background:none;
  margin:0;
  padding:3px 0;
  border-width:0;
  overflow:visible;
  font:100%/1.2 Arial,Sans-serif;
  text-decoration:none;
  color:#333;
  }
* html button.btn {
  padding-bottom:1px;
  }
/* Immediately below is a temporary hack to serve the 
   following margin values only to Gecko browsers
   Gecko browsers add an extra 3px of left/right 
   padding to button elements which can't be overriden.
   Thus, we use -3px of left/right margin to overcome this. */
html:not([lang*=""]) button.btn {
  margin:0 -3px;
  }
.btn span {
  background:#f9f9f9;
  z-index:1;
  margin:0;
  padding:3px 0;
  border-left:1px solid #ccc;
  border-right:1px solid #bbb;
  }
* html .btn span {
  padding-top:0;
  }
.btn span span {
  background:none;
  position:relative;
  padding:3px .4em;
  border-width:0;
  border-top:1px solid #ccc;
  border-bottom:1px solid #bbb;
  }
.btn b {
  background:#e3e3e3;
  position:absolute;
  z-index:2;
  bottom:0;
  left:0;
  width:100%;
  overflow:hidden;
  height:40%;
  border-top:3px solid #eee;
  }
* html .btn b {
  top:1px;
  }
.btn u {
  text-decoration:none;
  position:relative;
  z-index:3;
  }

/* pill classes only needed if using pill style buttons ( LEFT | CENTER | RIGHT ) */
button.pill-l span {
  border-right-width:0;
  }
button.pill-l span span {
  border-right:1px solid #ccc;
  }
button.pill-c span {
  border-right-style:none;
  border-left-color:#fff;
  }
button.pill-c span span {
  border-right:1px solid #ccc;
  }
button.pill-r span {
  border-left-color:#fff;
  }

/* only needed if implementing separate hover state for buttons */
.btn:hover span, .btn:hover span span {
  cursor:pointer;
  border-color:#9cf !important;
  color:#000;
  }

/* use if one button should be the 'primary' button */
.primary {
  font-weight:bold;
  color:#000;
  }

2 - 使用以下方法之一来调用它(更多内容可以在上面的链接中找到)

<a href="#" class="btn"><span><span><b> </b><u>button</u></span></span></a>

<button type="button" class="btn"><span><span><b> </b><u>button</u></span></span></button>

-- EDIT -- I didn't see the link in the original post. Sorry! Will try and re-write to reflect actual question

StopDesign has an excellent post on this here. [edit 20091107] These were released as part of the closure library: see the button demo.

Basically the custom buttons he shows are created using a simple bit of CSS.

He originally used 9 tables to get the effect: 9 Tables

But later he used a simple 1px left and right margin on the top and bottom borders to achieve the same effect.

The gradient is faked by using three layers: Button Gradient

All of the code can be found at the Custom Buttons 3.1 page. (although the gradient without the image is only working in Firefox and Safari)

Step by Step Instructions

1 - Insert the following CSS:

/* Start custom button CSS here
---------------------------------------- */
.btn {
  display:inline-block;
  background:none;
  margin:0;
  padding:3px 0;
  border-width:0;
  overflow:visible;
  font:100%/1.2 Arial,Sans-serif;
  text-decoration:none;
  color:#333;
  }
* html button.btn {
  padding-bottom:1px;
  }
/* Immediately below is a temporary hack to serve the 
   following margin values only to Gecko browsers
   Gecko browsers add an extra 3px of left/right 
   padding to button elements which can't be overriden.
   Thus, we use -3px of left/right margin to overcome this. */
html:not([lang*=""]) button.btn {
  margin:0 -3px;
  }
.btn span {
  background:#f9f9f9;
  z-index:1;
  margin:0;
  padding:3px 0;
  border-left:1px solid #ccc;
  border-right:1px solid #bbb;
  }
* html .btn span {
  padding-top:0;
  }
.btn span span {
  background:none;
  position:relative;
  padding:3px .4em;
  border-width:0;
  border-top:1px solid #ccc;
  border-bottom:1px solid #bbb;
  }
.btn b {
  background:#e3e3e3;
  position:absolute;
  z-index:2;
  bottom:0;
  left:0;
  width:100%;
  overflow:hidden;
  height:40%;
  border-top:3px solid #eee;
  }
* html .btn b {
  top:1px;
  }
.btn u {
  text-decoration:none;
  position:relative;
  z-index:3;
  }

/* pill classes only needed if using pill style buttons ( LEFT | CENTER | RIGHT ) */
button.pill-l span {
  border-right-width:0;
  }
button.pill-l span span {
  border-right:1px solid #ccc;
  }
button.pill-c span {
  border-right-style:none;
  border-left-color:#fff;
  }
button.pill-c span span {
  border-right:1px solid #ccc;
  }
button.pill-r span {
  border-left-color:#fff;
  }

/* only needed if implementing separate hover state for buttons */
.btn:hover span, .btn:hover span span {
  cursor:pointer;
  border-color:#9cf !important;
  color:#000;
  }

/* use if one button should be the 'primary' button */
.primary {
  font-weight:bold;
  color:#000;
  }

2 - Use one of the following ways to call it (more can be found in the links above)

<a href="#" class="btn"><span><span><b> </b><u>button</u></span></span></a>

or

<button type="button" class="btn"><span><span><b> </b><u>button</u></span></span></button>
两仪 2024-07-20 10:44:52

据 Firebug 称,这是他们的“存档”按钮。

<div tabindex="0" act="7" class="goog-imageless-button goog-inline-block goog-imageless-button goog-imageless-button-collapse-right goog-imageless-button-primary" id="">
  <div class="goog-inline-block goog-imageless-button-outer-box">
    <div class="goog-inline-block goog-imageless-button-inner-box">
      <div class="goog-imageless-button-pos">
        <div class="goog-imageless-button-top-shadow"> </div>
        <div class="goog-imageless-button-content"><b>Archive</b></div>
      </div>
    </div>
  </div>
</div>

CSS 超出了我的组织/粘贴范围。 也许只有我这么认为,但是当标记/CSS变得如此繁重时,我想我宁愿使用图像(或几个图像作为背景。更好的是,Sprites)。 此外,这个按钮的图像不会超过一个 K。

尽管我很喜欢 Google,但这似乎有点过分了。


更新:
谷歌是一个独特的案例。 如果您是一个大型网站并且希望将您的内容国际化,那么这种无图像技术实际上非常酷。 它允许您将几乎任何书面语言应用到您的 UI,而无需生成新图像,也无需担心破坏按钮。

请参阅问题:使用无图像按钮有哪些优点?< /a>

This is their "Archive" Button, according to Firebug.

<div tabindex="0" act="7" class="goog-imageless-button goog-inline-block goog-imageless-button goog-imageless-button-collapse-right goog-imageless-button-primary" id="">
  <div class="goog-inline-block goog-imageless-button-outer-box">
    <div class="goog-inline-block goog-imageless-button-inner-box">
      <div class="goog-imageless-button-pos">
        <div class="goog-imageless-button-top-shadow"> </div>
        <div class="goog-imageless-button-content"><b>Archive</b></div>
      </div>
    </div>
  </div>
</div>

The CSS is more than I care to organize/paste for this. Perhaps it's just me, but when the markup/css become this heavy, I think I would much rather USE AN IMAGE (or a couple images as backgrounds. Better yet, Sprites). Besides, an image for this button would be less than a single K.

As much as I love Google, this seems a bit overkill.


Update:
Google is a unique case. If you're a massive site and you wish to internationalize your content, then this image-less technique is actually really cool. It allows you to apply just about any written language to your UI, without needing to generate new images, or fear of breaking your buttons.

See Question: What are the advantages of using an imageless button?

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