固定按钮上的可点击区域较小

时间:2019-06-30 06:44:30

标签: html css button fixed

我正在设置一个呼叫按钮,该按钮将悬停在网站的移动版本的内容上。单击按钮可打开与所有者联系人的模式。一切工作正常,只不过按钮的顶部对单击的响应太小。该按钮在以下页面上:http://torg.shahar.uz/kvartira/prodaja-kvartira-tashkent-0-125144

@media (max-width:768px) {
  .float2 {
    position: fixed;
    width: 60px;
    height: 60px;
    bottom: 40px;
    right: 30px;
    background-color: #24ac36;
    color: #FFF;
    border-radius: 50px;
    text-align: center;
    box-shadow: 2px 2px 3px #999;
  }
}

.my-float2 {
  font-size: 24px;
  margin-top: 18px;
}
<div>
  <div style="position:absolute; z-index:100; width:50px; height:50px; margin-left:150px;">
    <a href="#" class="float2" data-toggle="modal" data-target="#myModal">
      <i class="fa fa-phone my-float2"></i>
    </a>
  </div>
  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>

        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
          <p>Some text in the modal.</p>
          <p>Some text in the modal.</p>
          <p>Some text in the modal.</p>
          <p>Some text in the modal.</p>

        </div>

      </div>

    </div>
  </div>
</div>

2 个答案:

答案 0 :(得分:0)

一个独立的固定div应该可以解决问题。检查一下:

window.onload = () => {
  const target = document.querySelector(".call-me");
  target.addEventListener("click", () => {
    alert("I was clicked!");
  })
};
*, *::before, ::after {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 200vh;
}

.content {
  height: 100%;
  background-color: rgb(0, 157, 214);
}

.call-me {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60px;
  width: 60px;
  cursor: pointer;
  background-color: #449D44;
  position: fixed;
  right: 0;
  bottom: 0;
  margin: 10px;
  border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
}

.call-me > img {
  height: 40px;
  width: auto;
}
<div class="call-me">
  <img src="https://www.stickpng.com/assets/images/5a4525bd546ddca7e1fcbc83.png" />
</div>
<div class="content"></div>

此外,这里还有一个pen,因此您可以轻松地在移动屏幕上尝试一下:)

答案 1 :(得分:0)

“ float2” 按钮上有一个iframe元素“ __replain_widget”。因此,您必须使用z-index解决此问题。您必须将__replain_widget的z-index更改为0,并将“ float2” 更改为1,然后才能单击float2按钮...

相关问题