Bootstrap 3 - remove breakpoint between md and lg

拈花ヽ惹草 提交于 2019-12-04 21:40:24

问题


I'm using Bootstrap 3 and trying to remove/exclude the breakpoint between medium and large devices. I have a existing website which is optimised to 970px which looks great. What I am trying to do is remove the md > lg breakpoint so that even on large widescreen desktops the maximum body width is 970px and still centred.

Anyone know if there is a quickfix solution to this?

Any advice would be much appreciated

Decbrad


回答1:


If you're overriding the bootstrap breakpoint (and using containers properly), adding this below the bootstrap breakpoint media queries in the bootstrap CSS file should work for you.

If using LESS

@media (min-width: @screen-lg) { 
  .container {
      width: 970px;
   }
}

OR, you can simply override the bootstrap container in your own CSS (just make sure you load it after bootstrap.css)

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

OR you can find the media query in the bootstrap.css file on around line 1240 and simply change it there

@media (min-width: 1200px) {
  .container {
     width: 1170px;  /* change 1170 to 970 */
  }
}



回答2:


the less way is good but this one is more flexible and reliable:

@media (min-width: @screen-sm) { .container { width:@screen-md; } }

Because in bootstraps default values the width of @screen-md is 992px. Now you will just have a breakpoint for small devices (smartphones) and any other bigger devices. they will all get the same layout




回答3:


You can set a max width on the containers:

.container-fluid,
.container {
  // Disable large-desktop breakpoint.
  max-width: $container-md;
}

No need for media queries or anything.

The $container-md value is typically 970px, unless you changed the $grid-gutter-width. For LESS, replace the $ of variables with an @. For regular CSS, replace the variable with the hard coded pixel size.



来源:https://stackoverflow.com/questions/21290321/bootstrap-3-remove-breakpoint-between-md-and-lg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!