首页 > 解决方案 > 如何抵消我的 col 以便可以点击链接?

问题描述

我正在为移动版本的网站创建一个“类似应用程序”的菜单栏。这个栏有两个可点击的图标和一个位于中心的主按钮。即使我设法编写了 html/css,我也无法单击图标,因为“+”按钮位于图标顶部。有没有办法可以安排这个,以便用户能够点击菜单,加上和用户的图标?

这是我的设计:

在此处输入图像描述

我设法使用以下代码创建了这个设计(我使用的是 Bootstrap 4 和 Fontawesome)

.footer-container-mobile {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: 54px;
  background-color: #8ABE57;
  width: 100%;
  margin: 0 auto;
  padding: 10px 40px;
  box-shadow: 0px -4px 8px rgba(0, 0, 0, 0.1);
}

.footer-container-mobile i {
  color: white;
  font-size: 1.3em;
  margin-top: 5px;
}

.circle-btn-mobile {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background-color: #31353C;
  color: white;
  text-align: center;
  align-items: center;
  font-size: 2em;
  filter: drop-shadow(0px 0px 13px rgba(0, 0, 0, 0.47));
  display: flex;
  flex-direction: row;
}

.circle-btn-mobile-container {
  z-index: 50;
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

<div class="container-fluid">
  <div class="row d-flex footer-container-mobile">
    <a href="#" class="mr-auto"><i class="far fa-bars"></i>Icon</a>
    <a href="#" class="ml-auto"><i class="fas fa-user-plus">Icon</i></a>
  </div>

  <div class="row circle-btn-mobile-container">
    <div class="d-flex justify-content-center mx-auto circle-btn-mobile">
      <i class="far fa-plus">+</i>
    </div>
  </div>

</div>

标签: htmlcssbootstrap-4

解决方案


为容器添加width: fit-content;css ,并按如下方式进行类:circle-btn-mobile-containerm-automargin: auto;

<div class="row circle-btn-mobile-container m-auto">

.footer-container-mobile {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: 54px;
  background-color: #8ABE57;
  width: 100%;
  margin: 0 auto;
  padding: 10px 40px;
  box-shadow: 0px -4px 8px rgba(0, 0, 0, 0.1);
}

.footer-container-mobile i {
  color: white;
  font-size: 1.3em;
  margin-top: 5px;
}

.circle-btn-mobile {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background-color: #31353C;
  color: white;
  text-align: center;
  align-items: center;
  font-size: 2em;
  filter: drop-shadow(0px 0px 13px rgba(0, 0, 0, 0.47));
  display: flex;
  flex-direction: row;
}

.circle-btn-mobile-container {
  width: fit-content;
  z-index: 50;
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

<div class="container-fluid">
  <div class="row d-flex footer-container-mobile">
    <a href="#" class="mr-auto"><i class="far fa-bars"></i>Icon</a>
    <a href="#" class="ml-auto"><i class="fas fa-user-plus">Icon</i></a>
  </div>

  <div class="row circle-btn-mobile-container m-auto">
    <div class="d-flex justify-content-center mx-auto circle-btn-mobile">
      <i class="far fa-plus">+</i>
    </div>
  </div>

</div>


推荐阅读