简体   繁体   English

如何使用Bootstrap修复div对齐

[英]How to fix divs alignment using Bootstrap

How, using bootstrap, I can align all div elements on the red line? 如何使用引导程序对齐红线上的所有div元素?

Incorrect: 不正确:
不在红线

Correct: 正确:
红线处

Content in div may not be same and this is a problem. div中的内容可能不相同,这是一个问题。 Divs where content is few paragraphs in the middle. 内容在中间是几段的Divs。 Where a lot of text otherwise. 否则很多文本。

And I need to put all divs top edges on the all pages to a one position. 我需要将所有页面上的所有div顶部边缘放到一个位置。

You need to update the bg2 class to this. 您需要将bg2类更新为此。 Yo have a margin top on it which is pushing the container to be larger and makes the gap. Yo上面有一个边距顶部,这将推动容器变大并产生间隙。 http://jsfiddle.net/dSK3P/2/ http://jsfiddle.net/dSK3P/2/

.bg2 { background-color: blue;margin-bottom: 20px;}

Maybe this jQuery code could help you. 也许这段jQuery代码可以为您提供帮助。 I use this code to separate nav bar from content or vice versa. 我使用此代码将导航栏与内容分开,反之亦然。

$(window).resize(function () {
    $('content').css('margin-top', parseInt($('#main-navbar').css("height"))+10);
});

$(window).load(function () {
    $('content').css('margin-top', parseInt($('#main-navbar').css("height"))+10);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM