gpt4 book ai didi

html - 使图像在特定位置可点击

转载 作者:太空宇宙 更新时间:2023-11-04 04:28:34 25 4
gpt4 key购买 nike

我正在尝试在我的图像上创建一个特定的可点击位置。图像大小会根据浏览器的大小动态调整,因此我也需要可点击框来执行此操作。我已经创建了一个盒子来包含我的图像(不确定是否有必要)并且认为如果我在该容器内制作一个盒子(a.resume),它会相对于图像进行调整。但是,该框似乎是在容器外部创建的,位于右侧的屏幕外。

下面是CSS:

#banner {
width: 100%;
margin-bottom: auto;
margin-top: auto;
margin-left: auto;
margin-right: auto;
}

img.banner {
max-width: 100%;
height: auto;
width: auto;
}

a.resume {
top: 20%;
left: 35px;
width: 60%;
height: 28%;
position: relative;
background-color: black; /* to see where my box is */
display:block;
}

下面是HTML:

<body>
<div id="banner">
<img src="banner.png" class="banner" />
<a href="banner1.png" class="resume" />
</div>
</body>

此外,如果您能告诉我我是否可以简化我的 CSS 或 HTML 中的任何内容,我将不胜感激。我是新手,我可能会使它们复杂化。

最佳答案

您需要使用 HTML map 标签。可以了解一下here

关于html - 使图像在特定位置可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17768552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com