我有三个并排的div,以及如何使它们折叠到小屏幕的标签中。
基本上,在大屏幕上都可以看到三个div,但是将其转换为与三个标签相对应的三个标签,并且只有处于活动状态的div的屏幕尺寸很小。
答案 0 :(得分:0)
HTML:
<div class="container">
<!-- Nav tabs -->
<ul class="nav nav-tabs device-small" 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>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active col col-xs-12 col-sm-4" id="home">...home...</div>
<div role="tabpanel" class="tab-pane col-xs-12 col-sm-4" id="profile">...profile...</div>
<div role="tabpanel" class="tab-pane col-xs-12 col-sm-4" id="messages">...messages...</div>
</div>
</div>
CSS:
@media (max-width: 767px) {
.device-big {
display: none;
}
.device-small {
display: block;
}
}
/* big device */
@media only screen and (min-width : 768px) {
.device-big, .tab-content > .tab-pane {
display: block;
}
.device-small {
display: none;
}
.tab-content > .tab-pane {
display: block;
}
}