CSS-使用绝对位置时链接不可单击

问题描述 投票:21回答:2

这是标题的HTML脚本:

<div class="header">
<div class="logo"><a href="Default.aspx"><img src="style/images/logo.png" alt="" /></a></div>
<div class="toplink"><a href="Signin.aspx">Sign in</a></div>
<div class="search">
    <form class="searchform" runat="server" method="get">
        <input type="text" id="s" name="s" value="Search for photos" onFocus="this.value=''" onBlur="this.value='Search for photos'"/>
    </form>
</div>
</div>

这是CSS脚本:

.logo {
    padding: 30px 0;
}

.logo img {
    display: inline;
} 

.toplink {
    position: absolute;
    bottom: 40px;
    right: 280px;
    font-size: 14px;
}

.search {
    position: absolute;
    bottom: 10px;
    right: 0;
    font-size: 14px;
    width: 330px;
}

以某种方式<< Sign in链接不可单击,但是当我删除绝对位置时,它可以正常工作。无论如何,可以在保持位置的同时使链接正常工作?任何建议表示赞赏,并在此先感谢。

-编辑-原来问题出在其他地方。实际上,我正在使用母版页,并使用它创建了一个默认的ASP页。仅当我测试该ASP页而不是用于创建母版页的HTML文件时,才会出现此问题。很抱歉,如果我听起来很复杂,但是,对我来说,这个问题有点复杂。希望有人可以指出我的原因。
html css hyperlink position clickable
2个回答
68
投票
尝试将z-index:10;添加到.toplink{...}类。

0
投票
我在绝对定位的div内有一个按钮,遇到了这个问题。 z-index还不够,我改用pointer-events: all
© www.soinside.com 2019 - 2024. All rights reserved.