【发布时间】:2021-09-30 01:29:47
【问题描述】:
我们的布局分为三个主要部分,顶部有主菜单,下面是主要内容和右侧的页面特定侧边栏。
主要内容和侧边栏由引导 col-* 类分隔。
当页面显示在小屏幕上时,我需要将右侧边栏移到主要内容上方,而不是下方(这是 bootstrap col 的默认行为)。一旦移动到顶部,还需要将其从 '' 转换为 ''。我试过 d-flex row-reverse 和 col-reverse 但这并没有改变任何东西。
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<main role="main">
<div class="container">
<div class="row d-flex">
<div class="col-sm-12 col-md-8">
this is the main content. this is the main content.this is the main content. <br />
this is the main content. this is the main content.this is the main content. <br />
this is the main content. this is the main content.this is the main content. <br />
this is the main content. this is the main content.this is the main content. <br />
this is the main content. this is the main content.this is the main content. <br />
this is the main content. this is the main content.this is the main content. <br />
this is the main content. this is the main content.this is the main content. <br />
</div>
<div class="col-sm-12 col-md-4">
<h3>Sidebar</h3>
<ul class="list-group">
<li class="list-group-item"><a href="#">Sidebar Link 1</a></li>
<li class="list-group-item"><a href="#">Sidebar Link 2</a></li>
<li class="list-group-item"><a href="#">Sidebar Link 3</a></li>
<li class="list-group-item"><a href="#">Sidebar Link 4</a></li>
<li class="list-group-item"><a href="#">Sidebar Link 5</a></li>
</ul>
</div>
</div>
</div>
</main>
【问题讨论】:
-
您希望边栏在长度小于或等于 576 像素的屏幕上移到顶部吗?通过应用 (sm),您可以对大于 576px 的屏幕应用样式
标签: javascript html css bootstrap-4