简体   繁体   English

Bootstrap-在将容器固定到底部时如何保持容器自然布局?

[英]Bootstrap - How to keep the natural container layout while fixing the container to the bottom?

I am having a Bootstrap one-page website, which uses a full-screen background. 我有一个Bootstrap单页网站,该网站使用全屏背景。 All content should be contained within the visible screen without having to scroll; 所有内容都应包含在可见屏幕中,而无需滚动; ie I want to exactly position different elements with a fixed position. 即我想用固定位置精确定位不同的元素。

I am currently stuck while trying to fix a container containing 3 equal columns. 我目前在尝试修复包含3个相等列的容器时陷入困境。 When I am fixing the container and position it 70px above the bottom, the columns move to left instead of keeping the natural centered position: 当我固定容器并将其定位在底部上方70px处时,列将向左移动而不是保持自然居中位置:

HTML 的HTML

<div class="container front-page-widgets">

  <div class="row">

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

      <?php if ( dynamic_sidebar( 'front-left' ) ); ?>

    </div>
    <div class="col-md-4">

      <?php if ( dynamic_sidebar( 'front-center' ) ); ?>

    </div>
    <div class="col-md-4">

      <?php if ( dynamic_sidebar( 'front-right' ) ); ?>

    </div>
  </div>

</div>

CSS 的CSS

.front-page-widgets {
    position: fixed;
    bottom: 70px;
}

Would appreciate your advise how to keep the natural container layout while fixing the container to the bottom. 在将容器固定到底部的同时,如何保持容器自然布局,请多多指教。

Surely your .container moves to left because you set the position: fixed and it sticks to the very left site as designed. 您的.container肯定会.container移动,因为您设置了position: fixed并且按设计.container在最左边的位置。

If you want to center the Bootstrap's .container horizontally while position: fixed is applied you may need to add left: 0 and right: 0 to achieve that. 如果要在应用position: fixed同时使Bootstrap的.container水平居中,则可能需要添加left: 0right: 0来实现。

Works on all resolutions. 适用于所有分辨率。

Bootply ex. Bootply前。

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

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