簡體   English   中英

如何向圖像添加鏈接 (href)

[英]How do I add a link (href) to the image

我想讓圖片成為一個鏈接,這樣當您點擊圖片時,它會將您帶到鏈接。

我嘗試了錨鏈接,但這不起作用。 下面是我的 HTML 和 CSS 代碼。

 .ideas-grid{ display: grid; grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr)); grid-gap: 2.5rem; margin-bottom: 2rem; } .title-heading{ text-align: center; text-transform: uppercase; margin-bottom: 10rem; color: rgba(0,0,0,.7); background-color: white; } .title-heading h1{ font-family: 'Aldrich', sans-serif; font-size: 2rem; margin: .5rem 0 1rem; text-align: center; } .title-heading p{ text-transform: none; padding: 0 50px; } .idea-grid-item{ height: 50rem; width: 50rem; padding: 5rem; color: white; position: relative; display: flex; flex-direction: column; justify-content: center; z-index: 1; } .idea-grid-item{ content:""; position: relative; top: 0; left: 0; width: 100%; height: 30rem; background-image: linear-gradient(135deg, rgba(49,24,131,0.9) 0%, rgba(72,56,149,0.8) 100%); z-index: -1; } .idea-grid-item p{ color: rgba(0, 0, 0, 0.7); } .idea-grid-item a{ float: right; }
 <div class="ideas-grid"> <!--Idea grid item 1--> <div class="idea-grid-item number-1"> <p> </p> <a href="https://www.instagram.com/p/B5NVsqhhp9O/?utm_source=ig_web_copy_link"></a> </div>

如果您希望整個圖像成為一個鏈接,請將其包裝在一個<a>元素中,如下所示:

<a href="http://yoursite.com">
    <img src="image.jpg" alt="">
</a>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <a href="https://sitelink.xyz"><img src="image.jpg"/></a>
</body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM