I am trying to create a number of square divs next too each other (which can expand in height if there is too much text..but most of the time there will not be too much text). I am trying to set it up in a responsive fashion.
When scrolling on the page, the address bar in my mobile browser keeps appearing and disappearing. When this happens when the phone is in landscape mode the dimensions change every time the address bar comes on or goes off. This creates a very annoying user experience.
My HTML code has the following viewport line in it:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
My code looks like this:
.block {
width: 80vmin;
min-height: 80vmin;
margin: 5% auto;
border-radius: 15vmin;
padding: 20px 10px;
}
Obviously, the culprit is the vmin component. If I do not specify vmin then the boxes are way too large when viewed in landscape mode.
Is there a way to get vmin to ignore the address bar and pretend it is not there? If not, what other options do I have to solve this problem?
If you design or develop websites, do not use px units. Absolute units ( px , in , mm , cm , pt , and pc ) are as bad for accessibility and responsive design as using tables for layout. Of all the available absolute units, pixels ( px ) are the only ones stubbornly sticking around.
Percentage is one of the most useful units for creating a responsive or fluid layout. Popular frameworks like Bootstrap, foundation, and Bulma use percentage for their base layout. Here the full-width class will be of 100% width of its parent element.
What Is Mobile Responsive Design? When a website is responsive, the layout and/or content responds or adapts based on the size of screen they are presented on. A responsive website automatically changes to fit the device you're reading it on.
You are (probably) a victim of CSS3 100vh not constant in mobile browser assuming that vh
changing is the reason for vmin
changing too.
Possible solutions:
vmax
in combination with aspect-ratio
media queries to estimate vmin
<meta name="viewport" content="width=device-width,height=device-height, initial-scale=1, user-scalable=no">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With