Can the max-height CSS media-query be utilized safely?

It seems that using the max-height media query is proving to be quite a challenge due to an issue with Chrome 67 on iOS.

The problem arises when users scroll on Chrome as it constantly adds and removes the address bar. This action causes the max-height value to change, resulting in a jumpy effect for elements styled using the max-height media query. For instance, if you have an image with dimensions of 300x500 but want to limit its height on shorter screens, a code snippet like this may be used:

@media (max-height: 700px) {
  img {
    max-height: 400px;
  }
}

This effectively translates to "if the screen is short, make the image short as well". However, the issue becomes apparent on Chrome iOS, particularly on devices like the iPhone X, where the constant addition and removal of the address bar triggers the media query unnecessarily.

https://i.sstatic.net/EsR2A.gif

When scrolling on a page containing multiple images, near the bottom, the sudden jumps can disrupt the user experience significantly. It's worth noting that Safari on iOS does not exhibit this behavior despite also toggling the display of the address bar.

While adjusting the max-height value could potentially solve the issue temporarily, this workaround may not be effective across all devices of varying heights. As a result, relying on max-height to trigger certain styles appears to be flawed. Is there a more stable solution to achieve the desired outcome?

Answer №1

It appears that the issue lies within iOS WkWebView and/or Chrome for iOS. The bug has been documented here, and if it gets resolved, it should fix the problem.

Link to Bug Report

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble with the auto width CSS for the center section of my webpage

I am facing an issue with assigning widths to my divisions using the CSS calc property. Despite setting the width for the first and last divisions, I am unable to allocate any width to the middle division. HTML: <div style="width:400px;"> <div ...

Alter Text Using Typewriter

Recently, I have been experimenting with code on my glitch website, trying to create typewriter text. Thanks to help from a user on StackOverflow, I was able to achieve this effect successfully. However, I am now facing a new challenge. My goal is to make ...

Modification in background when PNG image is hovered upon

Having an issue in Chrome that doesn't occur in Firefox. When hovering over a PNG within a carousel plugin or dragging an element with Jquery, the hover image briefly distorts the background. Looking for a solution to improve user experience. Let me k ...

Stop the content inside a div box from wrapping around the edges when using Bootstrap

Utilizing bootstrap to structure a webpage, I have organized three divs next to each other within a row. The widths of the divs are set as follows: 2 columns, 6 columns, and 4 columns in a 12 column layout. The middle div has a minimum width defined. As a ...

I could really use some assistance with this project for my friend

Whenever I click on the image, it only displays two out of the three possible alerts. How can I make it show all three? Here's my code: <!DOCTYPE html> <html> <head> </head> <body> <img src="http://www.build ...

Is AsciiEffect.js compatible with CSS3DRenderer.js in combination with three.js/WebGL?

Having trouble using the AsciiEffect.js and CSS3DRenderer.js together, wondering if it's possible without tweaking... here's the concept var W = window.innerWidth, H = window.innerHeight; renderer = new THREE.CSS3DRenderer(); effect = new THREE. ...

Laravel: Issue with displaying stored images from the database

When using Laravel, I encountered an issue where the stored image from the database is not displaying: Even though $post->image has the location posts/1lSBv7Ana8Lonj9Au37IrujjnnEaYgzNWyamch33.jpeg, the image does not show up. The code snippet in index ...

Pick the item when the checkbox is selected

I am currently attempting to toggle the visibility of a select element based on whether a checkbox is checked or not, but it doesn't seem to be working as expected. My desired functionality is for the select element to be hidden upon page load and th ...

Is it possible to dynamically alter a CSS property using styled components when an onClick event occurs?

Hey there, I'm pretty new to React and currently exploring styled components for the CSS styling of my components. One of the components I've created is a button called SummonButton: const SummonButton = styled.button` height: 50px; borde ...

Retrieve the server code periodically and automatically refresh the form elements

Let's kick things off by explaining how the application functions: (please note there are multiple users on the page such as Patient M, Patient E, and so forth) 1) Check In: Next to Patient X's name, you will find a button labeled Check In. This ...

Guide on how to showcase an array in a string format using table rows in JavaScript or jQuery

After making an AJAX call to a PHP database, I receive a String as a result in my script. The format of the string is shown below: array(4) { [0]=> array(3) { ["id"]=> string(3) "181" ["number"]=> ...

What is the best way to place <a> links next to each other in the header?

Looking to align the links horizontally in the header using CSS, can someone assist me with this? <body> <nav> <div class="wrapper"> <a href="index.php"><img src="spaceship.png" alt="blogs logo& ...

Utilizing Google Maps within a responsive layout with 2 columns

Seeking guidance on integrating a map into the second column of a responsive website. Acknowledging that my code may not be optimal, as this is my first attempt at such a task. After a day of searching for solutions, I'm feeling quite desperate. HTML ...

Save JSON data in an HTML document or vice versa

Hey there, the title of this post might seem a bit unclear but I couldn't think of another way to phrase it. So here's the dilemma: I have some data that is JSON encoded and stored in a .json file: {"foo":"bar", "bar":"foo", "far":"boo"} Additi ...

What could be hindering the activation of my button click event?

Below is the js file I am currently working with: var ButtonMaximizer = { setup: function () { $(this).click(function(){ console.log("The maximize button was clicked!"); }); } }; $(docum ...

Retrieving boolean or string data from ASP.NET Web API on iOS devices

When working with JSON data, I can easily retrieve the value using a specific function: NSMutableArray *jsonArrayClass = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions ...

The SpringMvc tiles are failing to display the header and footer

One of the main components in my project is a file called tiles.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apa ...

Instructions on how to prompt users to register using a distinctive code

Currently in the process of constructing a website and I'm interested in setting restrictions on the number of users who can sign up for it. https://i.stack.imgur.com/JD2Ct.png In the image provided, there is a database in phpMyAdmin labeled as &apo ...

Extending the href value using jQuery at the end

Can someone help me with this link: <a id="Link" href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2745425453424b4b524940674e0a4355464e4909494253">[email protected]</a>?subject=I-Drain Bestellung& ...

Is there a way to invoke a function within a mat-error element?

I need to display an error message in my input field! The function will return true if both passwords match, otherwise it will return false. How can I invoke a boolean function inside mat-error! My Function: checkPasswords(): Boolean { // 'passwords& ...