Nesting container within a container bootstrap

后端 未结 3 1682
北恋
北恋 2021-01-02 11:59

I\'m have a little bit of trouble getting a definitive answer on containers in bootstrap. It\'s clear that you should not nest a .container within a .con

3条回答
  •  借酒劲吻你
    2021-01-02 12:26

    Yes, never nest a container inside another.

    From the Bootstrap Docs:

    Containers

    Bootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers to use in your projects. Note that, due to padding and more, neither container is nestable.

    You can wrap the .container inside custom class .outer-container which has 100% width. Set a width near 75% when the screen size is reduced to show that the inner container has smaller width.

    .outer-container {
      background: tomato;
      width: 100%;
    }
    .container {
      background: lightblue;
    }
    @media (max-width: 1200px) {
      .container {
        width: 75%;
      }
    }
    
    
    I am fixed

提交回复
热议问题