override bootstrap container width

不想你离开。 提交于 2019-12-04 03:01:00
iamnotsam

ORIGINAL + BEST PRACTICE: always move the .well outside of .container to stay idiomatic with Bootstrap.

UPDATE + IF ABOVE IS NOT AN OPTION: Given that you cannot easily modify .container styles and/or move the .well outside of .container, your best bet is JavaScript. Here I have made a script that makes .well expand as the width of the window changes.

Here is a jsFiddle

The idea is that you want a negative value for margin-left and margin-right so that .well expands across the screen.

The div container has the following max-width specified in media query as default by bootstrap.

@media (min-width: 768px){
  .container{
    max-width:750px;
  }  
}

@media (min-width: 992px){
  .container{
    max-width:970px;
  }
}

To override this add the below style in your stylesheet

// This should be added in default styles, not within media query .container{ margin:0; padding:0; }

@media (min-width: 768px){
  .container{
    max-width:100%;
  }  
}

@media (min-width: 992px){
  .container{
    max-width:100%;
  }
}
Gonzalo

Here theres a simpler trick that works like a charm: https://css-tricks.com/full-width-containers-limited-width-parents/

Look for: "No calc() needed"

HTML

<header>
    <div class="container">
        <div class="content"></div>
        <div class="well full-width"></div>
        <div class="content"></div>
    </div>
    <footer>

CSS

.full-width {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!