gpt4 book ai didi

html - 防止侧边栏下推内容,在小屏幕上放在中间

转载 作者:行者123 更新时间:2023-11-28 07:57:05 25 4
gpt4 key购买 nike

我遇到了不同高度的右侧边栏将左侧的其他内容向下推的问题,如下所示:

a right-sidebar of varying heights pushing down other content that's on the left .

我的主要内容在 col-md-9 div 中,边栏在 col-md-3 div 中,评论应该在另一个 col-md-9 div 中主要内容的正下方。现在如果侧边栏超长,评论会被下推,所以它们从左侧开始,侧边栏在右侧结束。但是,当我将屏幕变小时,流程是正确的:主要内容、侧边栏内容和评论,如下所示:

the flow is correct: main content, content from sidebar, and comments .

我试过添加行、删除行、更改 div 的顺序以及更改 float 方向。当侧边栏很长时,我该怎么做才能摆脱多余的空间并让三个 div 在较小的屏幕上按正确的顺序排列,如下所示:

How I want the medium-width screen to look

这是一般的代码:

<div class="col-md-9">
MAIN CONTENT
</div>
<div class="col-md-3">
<h2>Sidebar</h2>
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
</div>
<div class="col-md-9">
<h1>Conversation:</h1>
<h2>COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS COMMENTS
</div>

这里是 a CodePen我一直在玩。

最佳答案

您必须重新排列您的 div 才能解决该问题。另外,您应该最后重视侧边栏。

<div class="row">

<div class="col-md-9">

<div class="row">

<div class="col-md-12">
Content
</div>

<div class="col-md-12">
Comment
</div>

</div><!--row-->

</div><!--col-md-9-->

<div class="col-md-3">
Sidebar
</div><!--col-md-3-->

</div><!--main-row-->

关于html - 防止侧边栏下推内容,在小屏幕上放在中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30044908/

25 4 0