PNG 叠加使 asp 超链接无法点击

发布于 2024-08-09 16:27:41 字数 811 浏览 8 评论 0原文

我已经设法让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

懵少女 2024-08-16 16:27:41

我不完全确定你想要实现什么,如果你想要的是一个图像,你可以像链接一样点击,你可以使用这个:


HyperLink

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>

我们的影子 2024-08-16 16:27:41

我不知道“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.

雨的味道风的声音 2024-08-16 16:27:41

感谢您的回复。超链接正在从数据库获取图像,我想在顶部覆盖一个相框。我使用 css 和绝对定位来定位 png 图像,但是一旦 png 图像位于顶部,我就丢失了链接。我现在将代码更改为:

<div class="ProductItem">

            <div class="picture">
                <asp:Image ID="imgProduct" runat="server" />

                <asp:HyperLink ID="testHyperlink" CssClass="pictureLink" runat="server" >
                <asp:Panel ID="productPanel" runat="server" ></asp:Panel>

                </asp:HyperLink>

            </div>
        </div>

图像控件现在从数据库中提取图像,并且我在面板控件周围包裹了一个超链接控件。面板控件从 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:

<div class="ProductItem">

            <div class="picture">
                <asp:Image ID="imgProduct" runat="server" />

                <asp:HyperLink ID="testHyperlink" CssClass="pictureLink" runat="server" >
                <asp:Panel ID="productPanel" runat="server" ></asp:Panel>

                </asp:HyperLink>

            </div>
        </div>

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.

谁许谁一生繁华 2024-08-16 16:27:41

将所有内容(包括覆盖层)包装在 asp:hyperlink 中

<div class="ProductItem">

    <asp:HyperLink ID="testHyperlink" CssClass="pictureLink" runat="server" >
        <div class="picture">
            <asp:Image ID="imgProduct" runat="server" />
            <asp:Panel ID="productPanel" runat="server" ></asp:Panel>
        </div>
    </asp:HyperLink>

</div>

您必须稍微更改一下 css,但这应该可以解决覆盖层的问题。

Wrap everything including your overlay in the asp:hyperlink

<div class="ProductItem">

    <asp:HyperLink ID="testHyperlink" CssClass="pictureLink" runat="server" >
        <div class="picture">
            <asp:Image ID="imgProduct" runat="server" />
            <asp:Panel ID="productPanel" runat="server" ></asp:Panel>
        </div>
    </asp:HyperLink>

</div>

You'll have to change your css around a bit but that should resolve your issue with the overlay.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文