简体   繁体   中英

How to fix divs alignment using Bootstrap

How, using bootstrap, I can align all div elements on the red line?

Incorrect:
不在红线

Correct:
红线处

Content in div may not be same and this is a problem. Divs where content is few paragraphs in the middle. Where a lot of text otherwise.

And I need to put all divs top edges on the all pages to a one position.

You need to update the bg2 class to this. Yo have a margin top on it which is pushing the container to be larger and makes the gap. http://jsfiddle.net/dSK3P/2/

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

Maybe this jQuery code could help you. 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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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