使用带有按钮标签的图标的首选机制是什么

发布于 2024-09-07 08:12:21 字数 300 浏览 6 评论 0原文

我已经看到以下 UI 代码片段,使用带有标签的图标

<a href="">
    <img alt src="img/save.gif" class="icon">
    <span>Save</span>
</a>

,或者

将其组合成单个实体(即图像图标加标签)是否有意义。

我担心的是,如果我们选择不同的主题(配色方案),那么我将无法为标签使用不同的颜色,并且可能必须重新生成图像。使用第一种方法使我可以灵活地这样做。

I have seen the following snippet of UI code to use icons with labels

<a href="">
    <img alt src="img/save.gif" class="icon">
    <span>Save</span>
</a>

OR

would it make sense to make combine this into a single entity (i.e. image icon plus the label).

My concern is if we choose a different theme (color scheme), then I will not be able to use different colors for my labels and might have to regenerate the image. Using the first approach gives me the flexibility to do so.

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

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

发布评论

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

评论(2

も让我眼熟你 2024-09-14 08:12:21

我不知道您正在使用的布局或颜色,但以下是我的观点:

  1. 当您分别拥有图像和文本时,图像和文本之间的相对对齐可能很难实现(以我基本的 HTML/CSS 知识)

  2. 你说你更喜欢将它们分开,因为你希望有可能在“配色方案更改”期间更改文本的颜色。但您确定不想同时更改图像(另一组图标)吗?您可能会遇到同样的颜色不匹配问题。 (您可以选择图标,使其与您网站的所有配色方案“一致”,然后您也可以以相同的方式选择标签的颜色)。

再次,我不确定您选择的布局/颜色,因此最终的答案是(一如既往)“取决于您的网站”

I dont know about the layout or the colors you are using but the following are my points:

  1. Relative alignment between the image and the text can be difficult to acheive (with my basic HTML/CSS knowledge) when you have the two separately

  2. You cay that you prefer to have them separate because you want the possibility to change the color of text during "color scheme changes". But are you sure you dont want to change the images as well (another set of icons)? You might have the same problem of color mismatches. (You might choose the icons in such a manner that they "go along" with all the color schemes of your site, then again you can choose the color of your labels in the same menner).

Again, I am not sure of the layout/colors you are choosing, so the definitive answer is (as always) "depends on your site"

爱的十字路口 2024-09-14 08:12:21

考虑常见链接图标的超链接提示。例如:

html

<a href="files/holidays.pdf">View Holidays</a>

CSS

a[href $='.pdf'] { 
       padding-right: 18px;
       background: transparent url(icon_pdf.gif) no-repeat center right;
    }

的各个样式都可以在 CSS 中处理。适用于几乎所有文件类型扩展名。这可能不适用于您的特定示例(必须查看更大的上下文),但对于下载链接等来说,这是一个很好的技巧。

Consider hyperlink cues for common link icons. For example:

html

<a href="files/holidays.pdf">View Holidays</a>

CSS

a[href $='.pdf'] { 
       padding-right: 18px;
       background: transparent url(icon_pdf.gif) no-repeat center right;
    }

Styling of each can be handled in CSS. Works for just about every file type extension out there. This might not work for your specific example (would have to see the larger context) but it's a great trick for download links, etc.

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