【问题标题】:Is there a way where I can enlarge any texts/pictures with the link tag, <a>, using only HTML/CSS? [duplicate]有没有一种方法可以只使用 HTML/CSS 来放大带有链接标签 <a> 的任何文本/图片? [复制]
【发布时间】:2023-03-03 12:11:01
【问题描述】:

对于我的网站,如果用户将鼠标悬停在包含链接的图片或文本行上,我希望将文本或图片放大并变大。一旦用户停止将鼠标悬停在文本/图像上,我希望文本/图像减小到其原始大小。

有什么办法可以做到这一点吗?感谢您的帮助!

【问题讨论】:

  • 我是否因为问题的格式错误而被否决了?
  • 这能回答你的问题吗? Image Enlarge on HoverIncrease text size on hover
  • @HereticMonkey 这使用了一些我以前没有学过的东西。但是,我将尝试学习它们并实施它们。谢谢!
  • 如果您将鼠标悬停在向下箭头上,它会列出拒绝投票的原因。

标签: html css hover


【解决方案1】:

您可以在 CSS 中使用 :hover 标记。

示例代码:

<!DOCTYPE html>
<html>
<head>

<style>
img:hover {
  width: 500px;
  height: 500px;
}
</style>
</head>

<img src="https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg">
<p>When hovering on the image, it will become bigger.</p>

</body>
</html>

你应该为它使用一个特殊的类。据我所知,无法为所有链接的图像启用此功能。

【讨论】:

  • 我在评论中链接到的重复问题显示了如何对任何图像执行此操作;使用transform: scale(2) 而不是设置绝对宽度和高度。
猜你喜欢
  • 2016-02-02
  • 1970-01-01
  • 2017-08-17
  • 2018-09-25
  • 1970-01-01
  • 2023-03-13
  • 2023-01-26
  • 1970-01-01
  • 2022-06-30
相关资源
最近更新 更多