html - 如何抵消我的 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>
解决方案
为容器添加width: fit-content;
css ,并按如下方式进行类:circle-btn-mobile-container
m-auto
margin: 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>
推荐阅读
- java - JVM 如何在内部使用以下表达式: Object c = new SomeClass();
- xcode - 无法在 Mac 上更新 CocoaPods
- nestjs - 如何在 Nestjs Fastify 适配器中使用 csrf 保护
- sql - SQL where exists 不一样的计数
- c - “列表”作为不合格的数据结构
- swift - 在放大代码片段的范围内找不到类型“AnyCancellable”
- python - 使用 Python 将网站解析为 CSV 文件
- java - 正则表达式 - 一个重复 2 个字母
- excel - Excel VB 使用列的单元格值作为网络爬虫的变量
- python - Python - 如何使用主键和排序键在 GSI 上查询 DynamoDB