html - 均匀分布 html 选项卡式菜单的按钮
问题描述
按钮向左对齐。我不知道如何使它们均匀分布并处于中心位置,以便响应
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
margin-top: 20px;
}
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
.tab button:hover {
background-color: #ddd;
}
.tab button.active {
background-color: #ccc;
}
<div class="tab">
<button class="tablinks">Today</button>
<button class="tablinks">This Week</button>
<button class="tablinks">This Month</button>
</div>
谢谢
解决方案
最简单的方法是为按钮添加 width:33%
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
margin-top: 20px;
}
.tab button {
width: 33.33%;;
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
.tab button:hover {
background-color: #ddd;
}
.tab button.active {
background-color: #ccc;
}
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
<div class="tab">
<button class="tablinks">Today</button>
<button class="tablinks">This Week</button>
<button class="tablinks">This Month</button>
</div>
推荐阅读
- python - Python - 跨越多个脚本的 tqdm 嵌套循环
- junit - 在 Junit 测试用例中 @Autowired 和 @Qualifier 显示无法加载应用程序上下文和非法状态异常
- excel - 根据特定标准对单元格进行分组
- logging - Dask:SSHCluster 工作人员在哪里登录?(KilledWorker 例外)
- c - C如何使用指针管理堆栈?
- c++ - 简化从文件读取的功能
- python - 为多个元素创建具有均值和标准差的直方图
- regex - 尝试按 OR 运算符对术语进行分组
- javascript - Font Awesome (4.7) 图标的悬停效果失败
- bash - 简单练习 bash 脚本