简体   繁体   English

div增加高度,并在Bootstrap中将div移动到它旁边

[英]div increases height, and moves a div next to it in Bootstrap

I'm using Bootstrap right now and i'm having an issue. 我现在正在使用Bootstrap,但遇到了问题。

This is my code: 这是我的代码:

<div id="calendario" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">...</div>
<div id="seccion" class="col-xs-12 col-sm-8 col-md-9 col-lg-6">...</div>
<div id="fotos" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">...</div>
<div id="secciondos" class="col-xs-12 col-sm-8 col-md-9 col-lg-6 col-lg-push-3">...</div>

My layouts look like this: 我的布局如下所示:

http://postimg.org/image/j387p9xvl/

But when my calendar height is bigger, this is what happens: 但是,当我的日历高度更大时,会发生以下情况:

http://postimg.org/image/am8pect6p/

What can I do to fix it?. 我该如何解决?

I have fixed it! 我已经解决了! :) :)

<div id="calendario" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">
    CALENDAR
</div>

<div id="seccion" class="col-xs-12 col-sm-8 col-md-9 col-lg-6">
    SECTION 1
</div>
<div class="clearfix visible-sm-block"></div>
<div class="clearfix visible-md-block"></div>
<div id="fotos" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">
    PICTURES
</div>
<div class="clearfix visible-lg-block"></div>
<div id="secciondos" class="col-xs-12 col-sm-8 col-md-9 col-lg-6 col-lg-push-3">
    SECTION 2
</div>

Just putting clearfix class where before the layout that is moved worked! 只需将clearfix类放在要移动的布局起作用之前的位置!

Thanks for the answers!!. 感谢您的回答!

I can't vote up your comments because I don't have enough reputation :(. 我不能投票赞成您的评论,因为我没有足够的声誉:(。

Using containers and rows as the Bootstrap team intended, it's easy to keep things aligned: 按照Bootstrap团队的意图使用容器和行,可以很容易地使事物保持一致:

<div class="container-fluid">
    <div class="row">
        <div id="calendario" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">Calendar
            <br>Calendar</div>
        <div id="seccion" class="col-xs-12 col-sm-8 col-md-9 col-lg-6">Section One</div>
    </div>
    <div class="row">
        <div id="fotos" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">Section Two</div>
        <div id="secciondos" class="col-xs-12 col-sm-8 col-md-9 col-lg-6 col-lg-push-3">Section Three</div>
    </div>
</div>

Demo 演示

You should use a wrapper around your calendar and make it .col-md-6 and then another around your second section and add the .col-md-6 class also. 您应该在日历周围使用包装纸,并将其设置为.col-md-6 ,然后在第二部分周围使用另一个包装,并添加.col-md-6类。 Like this, you would make sure that both your section will always talke half the screen. 这样,您将确保两个部分都始终讲话一半。 (You can also use other classes sm, xs and etc depeding on the layout you want to have) (您也可以在想要的布局上使用其他类,例如sm,xs等)

For example: 例如:

 <div class="col-md-6">
   <div id="calendario" class="col-xs-12 col-sm-4 col-md-3 col-lg-3">...</div>
 </div>
 <div class="col-md-6">
   <div id="seccion" class="col-xs-12 col-sm-8 col-md-9 col-lg-6">...</div>
 </div>

This way, you'd have to review also for example your seccion and calendar, because now the whol col-md-6 will contains 12 columns also. 这样,您还必须查看例如seccion和日历,因为现在whol col-md-6还将包含12列。 Hope it helped. 希望能有所帮助。 You might want to review the Grid system in there also: 您可能还想查看其中的Grid系统:

http://getbootstrap.com/css/#grid http://getbootstrap.com/css/#grid

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

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