有没有一种巧妙的方法来获取表示层中背景图像的归属?

发布于 2024-11-17 09:21:38 字数 1114 浏览 1 评论 0原文

我有一张由 CSS 引入的 CC-BY 图像,用作背景。这张图片纯粹是为了它的外观,绝对不是内容。我需要在某个地方对此图像进行归属,显然最好将此归属链接到提供该图像的好心人。但是,我真的不想将链接文本放入 HTML 中,因为这会破坏实际内容和演示文稿的分离(我想说,归因链接实际上是演示文稿的一部分,因为如果您在没有背景图像的情况下查看页面) ,你不会真的想看到它)。

有什么方法可以在这里将演示文稿和内容分开吗?

我当前的代码看起来像


<div class='backgrounded'>
  <div class='content'><h1>Some stuff here</h1></div>
  <div class='attribution'>
    Image from <a href='http://example.com/image'>Lovely CC-BY person</a>
  </div>
</div>

And the CSS:


div.backgrounded {
    background: url(/images/an_image.jpg);
}
div.attribution {
    color: #ffffff; 
    float: right;
}

This has the attribute in the content, 我宁愿没有它。

我考虑过的其他事情包括:

  • 将属性放入图像本身。 这解决了代码分离问题,但我的图像是一个位于左侧的漂亮宽图像,因此对于宽浏览器窗口有足够的背景。图像的右下角几乎总是看不见。 我不知道如何将此属性设置为链接。

  • 制作包含属性文本的图像,并将其放置在当前属性所在的位置,再次位于背景中,但位于顶部 我想我可以使用 JavaScript 将其设为链接。这看起来像是很多摆弄。

有没有办法解决这个问题,即我的图像仅在 CSS 中引用?或者如果做不到这一点,保持事物良好分离的最佳方法是什么,例如,可以在不编辑 HTML 的情况下替换图像?

I have a CC-BY image that I'm using as a background, brought in by CSS. This image is purely there for its looks, and definitely not content. I need to put attribution on this image somewhere, and obviously it would be nicest to make this attribution a link to the kind person who provided the image. However, I don't really want to put link text into my HTML as that breaks the separation of actual content and presentation (the attribution link is really part of the presentation, I would say, since if you viewed the page without the background image, you wouldn't really want to see it).

Is there any way I can get my separation of presentation and content right here?

My current code for this looks something like


<div class='backgrounded'>
  <div class='content'><h1>Some stuff here</h1></div>
  <div class='attribution'>
    Image from <a href='http://example.com/image'>Lovely CC-BY person</a>
  </div>
</div>

And the CSS:


div.backgrounded {
    background: url(/images/an_image.jpg);
}
div.attribution {
    color: #ffffff; 
    float: right;
}

This has the attribution in the content, where I'd rather not have it.

Other things I've considered include:

  • Putting the attribution in the image itself.
    This solves the code separation problem, but my image is a nice wide one positioned to the left so there is enough background for a wide browser window. The bottom right of the image is almost always out of view.
    I don't see how I can make this attribution a link.

  • Making an image containing the attribution text and putting that where the current attribution is, again in the background, but on top
    I guess I could make it a link using JavaScript. This seems like a lot of fiddling about.

Is there a way out of this where my image is only referred to in the CSS? Or failing that, what's the best way to keep things nicely separated, so that, for instance, the image could be replaced without editing the HTML?

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

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

发布评论

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

评论(2

千柳 2024-11-24 09:21:38

你可以在CSS本身中留下评论:

div.backgrounded {
    background: url(/images/an_image.jpg); /*Image provided by [name]*/
}

然后属性在CSS中,但在实际页面上不会可见。

You can leave a comment in the CSS itself:

div.backgrounded {
    background: url(/images/an_image.jpg); /*Image provided by [name]*/
}

Then the attribution is in the CSS, but it won't be visible on the actual page.

没︽人懂的悲伤 2024-11-24 09:21:38

CC-BY 许可证(可读版本)的相关部分是

归属 - 您必须归属
按照规定的方式工作
作者或许可人(但不以任何方式
这表明他们支持你或
您对作品的使用)。

这让我相信,除非指定了某种方式,否则您的自由裁量权是可以接受的。我认为像本页上所做的那样对背景图像进行处理是非常合理的:在底部你会发现一个

 site design / logo © 2011 stack exchange inc;

很容易符合 CC-BY 精神的谨慎的图像。在以 CC-BY 的形式在网络上发布了许多作品后,我的个人意图是“请不要假装是您创建的”,我认为这是该许可证的常见用途。

由于根据定义,您必须拥有归属信息,因此采取简单的方法,只需询问创建者“这样可以吗?”。

The relevant bit of the CC-BY license (readable version) is

Attribution — You must attribute the
work in the manner specified by the
author or licensor (but not in any way
that suggests that they endorse you or
your use of the work).

Which leads me to believe that unless a manner is specified your discretion is acceptable. I think it eminently reasonable to do for a background image as is done on this page: at the bottom you will find a discreet

 site design / logo © 2011 stack exchange inc;

which easily conforms to the spirit of CC-BY. Having put a number of creations out on the web as CC-BY, my personal intent was "just please don't pretend that you created it", which I think is a common use of that license.

Since you must, by definition, have the attribution information, take the easy route and just ask the creator "is this ok?".

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