html - 用于移动视图的触摸可滚动标签
问题描述
我正在尝试为移动视图制作 bootstrap 4 Touch Scrollable 选项卡 我已尝试调整此 bootstrap 3 代码:https ://bootsnipp.com/snippets/bpP0r#用于 bootstrap 版本 4
代码笔: https ://codepen.io/Bizboss/pen/zYGEOjO
HTML:
<div class="container">
<div class="row">
<div class="col">
<!-- Nav tabs -->
<div class="card">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
<li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
<li role="presentation"><a href="#about" aria-controls="about" role="tab" data-toggle="tab">About</a></li>
<li role="presentation"><a href="#contact" aria-controls="contact" role="tab" data-toggle="tab">Contacts</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<legend>Responsive Tabs</legend>
<p>If you are on desktop Try resizing the window to mobile view to see the scroll effect</p>
<p>Horizontal scrollable tabs</p>
<p>Best for mobile view</p>
<p>Similar to gravity MODE_SCROLLABLE in Android</p>
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<legend>Profile</legend>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
<div role="tabpanel" class="tab-pane" id="messages">
<legend>Messages</legend>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
<div role="tabpanel" class="tab-pane" id="settings">
<legend>Settings</legend>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passage..</div>
<div role="tabpanel" class="tab-pane" id="about">
<legend>About</legend>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into 1960s with the release of Letraset sheets containing Lorem Ipsum passage..</div>
<div role="tabpanel" class="tab-pane" id="contact">
<legend>Contact Us</legend>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passage..</div>
</div>
</div>
</div>
CSS:
body {
background: #EDECEC;
}
.nav-tabs {
display: inline-flex;
width: 100%;
overflow-x: auto;
border-bottom: 2px solid #DDD;
-ms-overflow-style: none; /*// IE 10+*/
overflow: -moz-scrollbars-none;/*// Firefox*/}
.nav-tabs>li.active>a,
.nav-tabs>li.active>a:focus,
.nav-tabs>li.active>a:hover {
border-width: 0;
}
.nav-tabs>li>a {
border: none;
color: #666;
}
.nav-tabs>li.active>a,
.nav-tabs>li>a:hover {
border: none;
color: #4285F4 !important;
background: transparent;
}
.nav-tabs>li>a::after {
content: "";
background: #4285F4;
height: 2px;
position: absolute;
width: 100%;
left: 0px;
bottom: 1px;
transition: all 250ms ease 0s;
transform: scale(0);
}
.nav-tabs>li.active>a::after,
.nav-tabs>li:hover>a::after {
transform: scale(1);
}
.tab-nav>li>a::after {
background: #21527d none repeat scroll 0% 0%;
color: #fff;
}
.tab-pane {
padding: 15px 0;
}
.tab-content {
padding: 20px
}
.nav-tabs::-webkit-scrollbar {
display: none; /*Safari and Chrome*/
}
.card {
background: #FFF none repeat scroll 0% 0%;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
margin-bottom: 30px;
display: block;
}
.nav>li>a {
position: relative;
display: block;
padding: 10px 15px;
}
但它不起作用!
任何人都可以帮忙吗?
解决方案
您的引导程序版本 ( ) 与您正在关注4.*.*
的教程 ( ) 不同3.*.*
您可以使用该版本3.*.*
或将此样式添加到您的 CSS 中:
.nav{
flex-wrap: inherit;
}
原因:版本4
将导航样式设置为 flex-wrap : wrap
推荐阅读
- amazon-web-services - AWS:对于查看器事件,您的 Lambda 函数的最大压缩大小不能超过 1 MB
- java - 单向 @OnetoMany 映射删除所有关系并重新添加剩余的关系,而不是删除特定的关系
- python - 为什么从方法参数中的环境变量读取在 python 中给出 None 或默认值。调用前设置环境变量
- javafx - 对对话框执行字段检查时未显示 JavaFX 警报
- css - 如何解决悬停 JSX 和 React 上扩展填充的 CSS 错误
- unity3d - 等轴测线上的弹跳球
- javascript - 你能用 github 托管一个不和谐的机器人吗?
- python - Python中的特定近似匹配
- numpy - 如何引用numpy数组的列?
- javascript - 如何在另一个数组中检索具有值的数组?