Is it possible to fix the issue with the height set to 100% on <body> not functioning properly in an Android web

Currently, my web app is functioning flawlessly in the browser as well as when saved to the home screen on both Android and iOS. However, I'm facing an issue where setting the height using a percentage unit (%) on the body element doesn't seem to work when the app is downloaded as a standalone application on Android (it works fine if set to a fixed pixel value). Additionally, some elements that use viewport height are also not rendering correctly, despite good support for viewport units. It's as if the viewport has no height at all.

The structure of the code is quite simple:

HTML:

<body>
  <div class="container">
    <div class="some-element"></div>
    <div class="some-element"></div>
  </div>
</body>

CSS:

body, html { height: 100%; }
.container { height: 100%; }
.some-element { height: 50vh; }

Could this issue possibly be related to the custom "shell" (which I wasn't involved in creating) used when the app is installed as a standalone app?

Answer №1

vh units are not well-supported on android devices, particularly for versions below 4.4. Unfortunately, if you are using an older android device, you may encounter issues with these units.

You can check the support for vh units at http://caniuse.com/#feat=viewport-units

Although vh and vw units have their benefits, I tend to avoid using them due to the lack of support on android devices.

If you are facing compatibility issues, consider styling a div as a table and using height:50% instead. Feel free to update your code and reach out for assistance if needed.

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

The field validation unexpectedly displays a null pointer exception even when it contains data

I am struggling with checking if the edittext is empty or not. When it's empty, I want to warn the user to input something, but the app crashes whether the field is empty or filled. The same error occurs in both scenarios: 01-08 09:34:34.989: E/Andro ...

Change the color of the first element when hovering over any of its siblings using only CSS

I am looking for a solution using only CSS We have 3 circles here. When I hover over circles with the class name "Mycircle", the circle with the class name "BigCircle" should change to red color HTML <div class="BigCircle"></div> <div cl ...

Styling with CSS in a React component

I am trying to display a row of buttons instead of columns on my webpage. I have used display:flex but it is still showing as a column. What I want is for each button to display the first character of its name underneath it, with all buttons lined up next ...

Error: the variable "ionic" has not been properly declared and defined

When testing the Ionic app, an error message "Uncaught ReferenceError: ionic is not defined" appears when opened in a browser. Additionally, the app shows a blank screen on mobile devices. Is there a solution to fix this issue? ...

What happens when browsers encounter unfamiliar at-rules?

CSS at-rules have been part of CSS since the days of CSS2. As CSS evolves with new specifications like @supports, it's interesting to see how different browsers handle unsupported rules. Do major browsers simply ignore unrecognized rules, or do they f ...

How can I fetch and show an image from a directory in Asp.Net Core 3.1 using a razor view?

What is the best way to retrieve an image from a directory and display it on a web page? "I've searched for solutions but haven't found one that works" I attempted this method, but it didn't yield the desired results Controller ...

Adjust the parent's cross-axis to fit the items

Is it feasible for the parent width to expand in a scenario where the parent implements display: flex; flex-direction: column, and a flex item wider than the parent needs to be accommodated? One important aspect to consider is that the grandparent element ...

Is file timestamp utilized by Apache to verify if a resource has been changed?

Currently, I am working on an HTML page that references a large JavaScript file (1MB+) that is rarely updated. According to this source, the JavaScript file will not be resent if it hasn't been modified. I'm curious about how Apache determines i ...

The app keeps crashing whenever the Jitsi Meet SDK is initiated, and it's proving difficult to pinpoint

I am encountering a problem with the app crashing when the Jitsi Meet SDK is initiated. The issue arises whenever I click on the "start meeting" button within the app. Below, I have attached a video and code snippet for reference. Link to the video package ...

The alignment of Bootstrap v4.5 checkbox is limited as it cannot be positioned horizontally or vertically when placed next to an input field

As stated in the title: Bootstrap's checkbox is having trouble aligning Horizontally or Vertically when placed next to an input. Error Displayed: https://i.sstatic.net/hNHpm.png I have experimented with various solutions, but none have provided sat ...

Tips for extracting data from div tags that share the same id

Html <!DOCTYPE html> <html> <body> <div id="one"> welcome <div class="two"> hello world </div> <div class="two"> bye world </div> < ...

Connecting to your localhost database from any location using Android Studio

My android application is currently using a localhost XAMPP database that is running on my laptop. The application itself is running on my phone. I am able to access the database on my phone only when both my laptop and phone are connected to the same net ...

Hover functionality is disabled when a div being hovered is nested inside another div

I am in the process of developing a webpage that showcases school events. I am attempting to create a div called "eventContainer" within which there is another div named "eventImgContainer" containing an image. When this image is hovered over, I want it to ...

`Open PhotoSwipe to view the image in a new window`

My goal is to open the current visible photo in a new window using JavaScript, while ensuring it works on an iPad as well. To achieve this, I added a button to the toolbar (similar to the example) and included its corresponding CSS in the photoswipe.css fi ...

Creating a separation line between divs using HTML and customized Bootstrap styling

I'm currently practicing with bootstrap and HTML, and I would appreciate it if you could take a look at the image I've included. In the image, I have successfully created and displayed a return flight. Moving forward, my goal is to enhance its ap ...

Flex just can't seem to align correctly

I'm having trouble getting this to work properly. I am using React and styled components, but the justify/content alignment is not functioning as expected. The setup includes a div with flex properties, where the flex direction is set to column. With ...

Hide the scroll bar in html/css while keeping the functionality of the arrows intact

Is there a way to remove the scroll bar but still be able to access overflown data using arrows? Any assistance would be greatly appreciated. Thank you in advance. ...

angularjs reset file input form

Whenever I click publish, I want to clear my form: $scope.product = {}; $scope.upload = function(user) { var formData = new FormData; $scope.product.owner = user; for (key in $scope.product) { ...

Converting ResponseBody to JSONObject in Retrofit for Android: A Step-by-Step Guide

When making an API call using Retrofit in Android and receiving a response from the POST method in the form of ResponseBody, I encountered an issue. The API call looks like this- @POST("api/auth/store-login") fun postLoginDetail(@Body userData: RequestBod ...

Ways to display HTML elements depending on the width of the window

Is there a way to create visually appealing hexagon containers for text that work well across all window widths? Currently, the design is only satisfactory at certain window sizes. I am looking to implement a solution where specific code will be displayed ...