【发布时间】:2017-10-24 15:49:44
【问题描述】:
我所做的是在我的页面底部创建了一个透明的 div,它与页面底部的固定 div 大小相同。当用户向下滚动时,固定 div 会显示在网站内容的其余部分下方。透明 div 位于固定 div 前面,因此用户无法点击固定 div 上的输入框等。
将pointer-events: none; 放在透明 div 上应该允许用户单击它,但不幸的是这并没有解决我的问题。我尝试制作透明和固定的 div display: block 或 display: inline-block,但这些都没有解决我的问题。
//empty transparent div
.section.empty-section {
height: 459px;
pointer-events: none;
display: inline-block;
}
//contact form under the transparent div
.section.footer {
background: #131313;
position: fixed;
bottom: 0;
z-index: -1;
}
.section {
position: relative;
padding: 10 10 10 10;
left: 0;
width: calc(100% - 20px);
color: white;
font-family: "Gadugi";
overflow: hidden;
background-size: contain;
background-repeat: no-repeat;
background-blend-mode: soft-light;
}
<div class="section empty-section"></div>
<div class="section footer">
<span class="heading">Contact</span>
<form action="contact.php" method="POST">
<label>Your email address</label>
<br>
<input type="email" name="from-email-address">
<br>
<br>
<label>Your name</label>
<br>
<input type="text" name="from-name">
<br>
<br>
<label>Your message</label>
<br>
<textarea class="email-textbox" name="email-message"></textarea>
<br>
<button class="send-button">Send Email</button>
</form>
</div>
https://gyazo.com/83c3f870aa8c0775ca24cf08de71adcf这是我的页面的gif,底部的表单不可点击。
【问题讨论】:
-
这可能只是因为您将
z-index设置为-1。body和html元素正在捕获您的点击事件。 -
我将指针事件设置为无,所以我应该能够点击 div 对吧?
-
您是,但您没有点击
body或html。这些元素捕获事件并在您的表单之上。表单被设置为“低于”<html>和<body>,因为它们是z-index: -1。
标签: css html pointer-events