gpt4 book ai didi

html - Bootstrap 内容无法与固定宽度的侧边栏一起正确布局

转载 作者:可可西里 更新时间:2023-11-01 13:28:49 26 4
gpt4 key购买 nike

列的第一行和第二行之间有一个很大的白色间隙。

JSFiddle:https://jsfiddle.net/5o3ug26g/

<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<style>
.content {
margin-left: 170px;
margin-right: 170px;
}

.sidebar { width: 160px; height: 600px; }
.left { float: left; background: forestgreen; }
.right { float: right; background: steelblue; }
</style>
</head>


<body>
<div>
<div class="left sidebar"></div>

<div class="right sidebar"></div>

<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">Text on top of the page</div>
<div class="col-md-6">Other text on top of the page</div>
</div>

<div class="row">
<div class="col-md-6">I want this to be right below the "Text on top of the page" but it isn't...</div>
<div class="col-md-6">... and I want this to be right below the "Other text on top of the page" but it isn't</div>
</div>
</div>
</div>
</div>
</body>
</html>

如果我删除 row 类,那么间隙就会消失,但是当使用 Bootstrap navbar-s 和其他带有 :after { display 的容器时也会出现这个问题: table ; },因此仅删除 row 类不是解决方案。

我尝试在很多地方添加 clearfix 但无济于事。

这是一个更复杂的响应式布局的摘录,我宁愿避免重构它。

什么是最简单的修复?

最佳答案

您可以绝对定位左右边栏而不是 float 它们。 float 会干扰 Bootstrap 布局。

.left { background: forestgreen; position:absolute; left:0; top:0; }
.right { background: steelblue; position:absolute; right:0; top:0;}

从你的 fork 出来的实例:https://jsfiddle.net/5fk5900s/1/

关于html - Bootstrap 内容无法与固定宽度的侧边栏一起正确布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33287775/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com