html - 超链接图像
问题描述
鉴于我当前的代码,我将如何对图像进行超链接,以便当用户单击图像时,浏览器会打开一个新选项卡并显示图像?
body {
margin: 0;
padding: 0;
}
.img {
display: grid;
height: 100%;
}
.center-fit {
max-width: 100%;
max-height: 100vh;
margin: auto;
}
<div class="img"> <img class="center-fit" src='https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/1363px-Collage_of_Nine_Dogs.jpg'></div>
解决方案
这是最简单的方法。
<a href='https://anywebsite.com/home'>
<img class="center-fit" src='https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Collage_of_Nine_Dogs.jpg/1363px-Collage_of_Nine_Dogs.jpg' />
</a>
您可以将锚标记 ( <a href='...'> </a>
) 包裹在任何东西上,它会将其超链接到任何东西。
您也可以添加<a href='...' target='_blank' </a>
,它会
推荐阅读
- css - 定位左/右切换/触发器和下拉菜单的相应菜单
- javascript - Flutter 和 Openlayers - 包括 Flutter 中的 js 库
- php - Symfony 4 @UniqueEntity 不适用于 GEDMO 树复合字段
- visual-studio - Visual Studio 构建事件/构建新版本的目标
- python - 部署无服务器的 Django 应用程序?
- excel - BluePrism Excel 提取
- angularjs - angularjs ng-repeat 全选
- ios - 从音频可视化器的后台应用程序播放和录制音频
- python-3.6 - 错误:src/main/aerospike.c:17:20:致命错误:Python.h:没有这样的文件或目录;无法使用 python3 安装 aeropike
- angular - 如何重定向到登录页面会话过期?