链接时图像下方的边距

发布于 2025-01-03 14:08:26 字数 525 浏览 2 评论 0原文

我到处都找不到这个问题的答案,我想可能是因为没有人遇到过同样的问题,或者可能是因为这是一个非常具体的问题。

我遇到的问题是,当我正在处理的网站上的链接图像悬停在其上时,其下方有一个小边框,这在所有浏览器中都是如此(除了 IE 7,该网站最初是在该浏览器中设计的)。这是由于将 a:hover 设置为具有背景。尽管没有为图像设置边框、边距和填充,但由于某种原因它仍然不满意。

我只有两种方法来解决它,在某些标签上设置一个没有背景的类,或者将链接的图像显示为块。不幸的是,这两种解决方案都不合适,因为该网站有数百个页面,可能还有数千个链接图像,使用类意味着找到所有这些!使用显示块会破坏一些图像的显示,例如当它们在 ap 标签中很好地居中时。

如果您想要一个对我不起作用的示例,相关网站的主页是 http://www.tameside .gov.uk,看看右上角的社交媒体图标,它们都得到了背景悬停处理。

如果有人能提供帮助,我将非常感激。

谢谢,

I've looked everywhere and can't find an answer for this, I think possibly because nobody has had the same problem, or possibly because it's a very specific problem.

The problem I'm having is, that linked images on the site I'm working on, have a small border underneath when hovered over, this is in all browsers (apart from IE 7, which the site was designed originally in). This is due to setting a:hover as having a background. Despite setting no borders, margins and padding to images, it's still not happy for some reason.

I only have 2 ways to solve it, set a class with no background on certain a tags, or display the linked image as a block. Unfortunately both these solutions aren't suitable, because the site has hundreds of pages, and possibly thousands of linked images, using a class means finding them all! Using display block will break some of the displays of images, such as the when they're centered nicely in a p tag.

If you want an example of it not working for me, the homepage of the site in question is http://www.tameside.gov.uk, look at the social media icons in the top right, they're all getting the background hover treatment.

If anyone could help I'd be really grateful.

Thanks,

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

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

发布评论

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

评论(1

空城之時有危險 2025-01-10 14:08:26

图像图标为 PNG 且具有透明背景。这就是为什么你可以看到背景。
您可以将图标更改为白色背景(与 JPEG 相同),您将不再看到背景。

更快的修复方法是添加一条新的 CSS 规则,该规则仅适用于社交媒体 div 内的 a 标签:

.banner_container .social a {
    background: none !important;
}

The image icons are PNG and have a transparent background. That is why you can see the background.
You can change the icons to have white background (same them as JPEG) and you will no longer see the background.

A faster fix would be to add a new CSS rule that apply only to the a tags inside the social media div:

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