简体   繁体   English

自举屏幕尺寸的困境?

[英]bootstrap screen sizes dilemma?

Bootstrap has 4 screen sizes md, sm, lg and xs . Bootstrap具有4个屏幕尺寸md, sm, lg and xs

I just found that these screen sizes or breakpoints change with resolution. 我只是发现这些屏幕尺寸或断点随分辨率而变化。

I marked in my screen the breakpoint of md with different resolutions and all were different. 我在屏幕上用不同的分辨率标记breakpoint of mdbreakpoint of md并且它们都不同。

Now, my question is how can we make sure the layout is what we want since the screen breakpoints seem to vary with screen resolutions and different devices have different screen resolution? 现在,我的问题是,由于屏幕断点似乎随屏幕分辨率而变化,并且不同的设备具有不同的屏幕分辨率,我们如何才能确保布局是我们想要的?

It would be easy if the sm, md, lg and xs breakpoints were same for all devices but this doesn't seem to be the case. 如果sm, md, lg and xs breakpoints对于所有设备都是相同的,那将是很容易的sm, md, lg and xs breakpoints但事实并非如此。 I appreciate any help in solving this dilemma. 我感谢您为解决这一难题提供的帮助。 Thanks! 谢谢!

To avoid the breakpoints, you can switch to using container-fluid instead of container class for your containing DIV, like this: 为了避免断点,可以为包含的DIV切换为使用container-fluid而不是container类,如下所示:

<div class="container-fluid">
  ...
</div>

instead of: 代替:

<div class="container">
  ...
</div>

More information can be found here http://getbootstrap.com/css/#overview-container 可以在这里找到更多信息http://getbootstrap.com/css/#overview-container

please note that making all of the md, sm, lg and xs to break at the same screen size would be not a good solution. 请注意,使所有的md,sm,lg和xs都在相同的屏幕尺寸下中断并不是一个好的解决方案。 However you can do that - 但是,您可以这样做-

2 ways of achieving this: go to bootstrap.css and find all references to @media references and change them to the same value eg @media(max-width:480px) { ... } 实现此目的的2种方法:转到bootstrap.css,找到对@media引用的所有引用,并将其更改为相同的值,例如@media(max-width:480px){...}

or other way is to recompile less => css go to variables.less - go to line 248: https://github.com/twbs/bootstrap/blob/master/less/variables.less 或其他方法是少编译=> css转到variables.less-转到第248行: https : //github.com/twbs/bootstrap/blob/master/less/variables.less

and update the values on all the screen sizes. 并更新所有屏幕尺寸上的值。 then compile it and boom you have it. 然后编译它,让您拥有它。

hope that helps 希望能有所帮助

To ensure all of the layouts stays the same of all of the devices just target the XS breakpoint. 为确保所有布局均与所有设备相同,只需将XS断点作为目标即可。

 <div class="container-fluid">
    <div class="row">
        <div class="col-6"> Half of the screen</div>
        <div class="col-6"> Half of the screen</div>
    </div>
</div>

or you can just use flexbox solution 或者您也可以使用flexbox解决方案

<div class="container-fluid">
    <div class="row">
        <div class="col"> Half of the screen</div>
        <div class="col"> Half of the screen</div>
    </div>
</div>

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

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