PNG 叠加使 asp 超链接无法点击
我已经设法让 PNG 覆盖层出现在 asp:hyperlink 图像上,但这意味着超链接无法单击,有没有办法解决这个问题?
<div class="ProductItem">
<div class="picture">
<asp:HyperLink ID="hlImageLink" runat="server" />
<div class="overlay"></div>
</div>
</div>
.HomePageProductGrid .ProductItem
{
text-align: center;
margin: 10px 10px 10px 10px;
width: 310px;
height: 410px;
background-repeat:no-repeat;
position:relative;
}
.HomePageProductGrid .ProductItem .picture
{
text-align: center;
position:relative;
padding-top:43px;
}
.HomePageProductGrid .overlay
{
background: url(images/frame1.png) no-repeat;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
width: 310px;
height: 410px;
}
I've managed to get a PNG overlay to appear over an asp:hyperlink image, but this now means the hyperlink is unclickable, is there a way around this ?
<div class="ProductItem">
<div class="picture">
<asp:HyperLink ID="hlImageLink" runat="server" />
<div class="overlay"></div>
</div>
</div>
.HomePageProductGrid .ProductItem
{
text-align: center;
margin: 10px 10px 10px 10px;
width: 310px;
height: 410px;
background-repeat:no-repeat;
position:relative;
}
.HomePageProductGrid .ProductItem .picture
{
text-align: center;
position:relative;
padding-top:43px;
}
.HomePageProductGrid .overlay
{
background: url(images/frame1.png) no-repeat;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
width: 310px;
height: 410px;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不完全确定你想要实现什么,如果你想要的是一个图像,你可以像链接一样点击,你可以使用这个:
I'm not entirly sure what it is you are trying to achive, if what you want is an image you can click like a link you can use this:
<asp:HyperLink ID="HyperLink1" runat="server" ImageUrl="~/Images/MyPic.png" NavigateUrl="~/MyPage.aspx">HyperLink</asp:HyperLink>
我不知道“asp:hyperLink”是如何工作的,但是您是否尝试过给它一个比覆盖层更大的 z-index ?该链接可能需要position:relative 才能正常工作。
I don't know how "asp:hyperLink" works but have you tried giving it a z-index larger than the overlay? The link might need position: relative for it to work.
感谢您的回复。超链接正在从数据库获取图像,我想在顶部覆盖一个相框。我使用 css 和绝对定位来定位 png 图像,但是一旦 png 图像位于顶部,我就丢失了链接。我现在将代码更改为:
图像控件现在从数据库中提取图像,并且我在面板控件周围包裹了一个超链接控件。面板控件从 4 个帧中选择一个随机相框图像。数据库图像的 URL 被馈送到超链接控件。
现在,当您加载页面时,每个产品都有一个随机框架,并且链接会将您带到相关的产品页面。
Thanks for replying. The hyperlink is getting an image from the database and i wanted to overlay a picture frame over the top. I was positioning the png image using css and absolute positioning but as soon as the png image was on top i lost the link. I've now changed the code around to this:
The image control now pulls the image from the database, and i've wrapped a hyperlink control around a panel control. The panel control gets a random picture frame image from a selection of 4 frames. The url for the database image is fed to the hyperlink control.
Now when you load the page each product has a random frame and the link takes you to the relevant product page.
将所有内容(包括覆盖层)包装在 asp:hyperlink 中
您必须稍微更改一下 css,但这应该可以解决覆盖层的问题。
Wrap everything including your overlay in the asp:hyperlink
You'll have to change your css around a bit but that should resolve your issue with the overlay.