I have a strange problem. The media query rules in my CSS trigger have a certain width, as intended, however, if I have already resized the browser window to a smaller width, and then expand the browser window outside, something strange will happen. Things seem normal until I refresh the page. The layout changes unexpectedly only when the page is refreshed. Of course, the goal is that media queries behave normally, as when refreshing a page, should not change any rules.
I tried to recreate the problem using bare bones:
* { box-sizing: border-box; } main { max-width: 600px; height: 11rem; margin: 0 auto; padding-top: 10px; font-size: 0.8rem; text-align: left; } .circle { width: 100px; height: 100px; background-color: #444; border-radius: 50%; float: left; top: calc( 50% - 10px ); } .about-container { width: 75%; float: right; } body button { display: block; margin: 0 auto; padding: 8px; }
<head> <style> @import url('https://necolas.imtqy.com/normalize.css/latest/normalize.css'); .clearfix:after { content: ""; display: block; clear: both; } .vertically-center { position: relative; top: 50%; transform: translateY( -50% ); } </style> </head> <body> <main class="clearfix"> <div class="circle vertically-center"></div> <div class="about-container"> <h3>About</h3> <p> This problem is wierd. When <strong>snippet is made full screen</strong> and browser width is shrunk to less than <strong>550px</strong> <em> ( You will know you're at 550px because the background will darken )</em> the layout changes - as expected. However when window is expanded beyond 550px again and <strong>Reload Frame</strong> is clicked the layout unexpectedly updates itself. <br><br>What going on? </p> </div> </main> <button onclick="location.reload()">Reload Frame</button> </body>
Although strange, I feel this is a simple solution, hope?
Edit: I see these results in the Chrome browser. A GIF will be loaded, which demonstrates what I see below.

css google-chrome media-queries css-float
sol acyon
source share