如何为SharePoint列表设置可点击跳转的图片链接
要让列表中的图片成为可点击的超链接,只需将图片元素嵌套到链接标签内部即可。修改后的Tile Formatting代码如下:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json", "hideSelection": true, "width": "355", "height": "355", "formatter": { "elmType": "div", "children": [ { "elmType": "div", "style": { "display": "inline-block", "min-width": "355px", "min-height": "355px", "margin-right": "10px", "box-shadow": "2px 2px 4px darkgrey" }, "children": [ { "elmType": "a", "style": { "border": "none", "display": "block", "cursor": "pointer" }, "attributes": { "target": "_blank", "href": "[$Link]" }, "children": [ { "elmType": "img", "attributes": { "src": "[$Image.serverRelativeUrl]" }, "style": { "height": "360px", "max-width": "360px" } } ] } ] } ] } }
关键修改说明:
- 将
<img>元素移入<a>标签的children数组,让链接完全包裹图片,点击图片即可触发跳转 - 给
<a>标签添加display: block样式,确保链接区域覆盖整个图片,避免点击图片边缘无效 - 如果需要保留底部的"Click here"文字,可将文字元素添加到
<a>标签的children中,调整样式让它显示在图片下方
内容的提问来源于stack exchange,提问作者SOny
相关产品推荐
相关产品推荐

