简体   繁体   English

媒体查询在调整窗口大小时没有响应,但是可以在Chrome Dev工具中使用

[英]Media query not responding on window resize, but working in Chrome Dev tools

So I'm trying to have a "list" (not an html list, but just 6 concurrent pictures in a logical fashion) of pictures that go down, but at a certain breakpoint, two move next to each other, and the media query is working in the Chrome dev tools and on Adobe Dreamweaver live preview on the phone, but on browser resize, the media query doesn't respond. 因此,我尝试创建一个“列表”(不是html列表,但只有6个并发图片以逻辑方式),这些图片会下降,但是在某个断点处,两个彼此相邻,并且进行媒体查询正在使用Chrome开发人员工具和手机上的Adobe Dreamweaver实时预览,但是在调整浏览器大小时,媒体查询没有响应。 Here is the html : 这是html

    <div class="gray-bg">
          <!-- Item 1 -->
            <div class="flexbox-row">
              <div class="sec-heading space-between">
                   <img src="assets/images/header1Web.png" class="img-responsive" alt="Cinque Terre" usemap="#plus">
              <map name="plus" id="plus"><area alt="" title="" href="#" shape="poly" coords="1904,371,1898,358,1890,351,1782,423,1917,426,1917,300,1891,321,1875,340,1803,401,1790,415,1782,418" /></map>
              </div>
            <!-- Item 2 -->
              <div class="sec-heading space-between">
                   <img src="assets/images/header2Web.png" class="img-responsive" alt="Cinque Terre">
              </div>
            </div>
          <!-- Item 3 -->
            <div class="flexbox-row">
              <div class="sec-heading space-between">
             <img src="assets/images/header3Web.png" class="img-responsive" alt="Cinque Terre">
             </div>
          <!-- Item 4 -->
              <div class="sec-heading space-between">
             <img src="assets/images/header4Web.png" class="img-responsive" alt="Cinque Terre">
             </div>
          </div>
          <!-- Item 5 -->
            <div class="flexbox-row">
              <div class="sec-heading space-between">
             <img src="assets/images/header5Web.png" class="img-responsive" alt="Cinque Terre">
             </div>
          <!-- Item 6 -->
              <div class="sec-heading space-between">
             <img src="assets/images/header6Web.png" class="img-responsive" alt="Cinque Terre">
             </div>
             </div>
    </div><!-- / .gray-bg -->

And here is the appropriate CSS : 这是合适的CSS

.flexbox-row {
    display: block;
}
@media only screen and (min-device-width: 1446px) {
.flexbox-row {
    display: flex;
}}

(min-device-width: 1446px) is different from (max-width: 1446px) , min-device-width is checking if you have a screen width of 1446px while (max-width: 1446px) is if you have current width of 1446px. (min-device-width: 1446px)(max-width: 1446px)min-device-width正在检查屏幕宽度为1446px,而(max-width: 1446px)是当前宽度为1446px。 No matter how you resize it the screen width is still the same. 无论您如何调整它的大小,屏幕宽度都相同。

Hope that helps 希望能有所帮助

to make the flexbox-row react "when the maximum width of the screen is 1446px" the code is: 使flexbox-row反应“当屏幕的最大宽度为1446px时”,代码为:

@media only screen and (max-device-width: 1446px) {
.flexbox-row {
    display: flex;
}}

and not 并不是

@media only screen and (min-device-width: 1446px) {
.flexbox-row {
    display: flex;
}}

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

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