The oversized monitor is cut off halfway due to postcss-pxtorem

When designing a screen with dimensions of 3840 x 2160, the initial draft was created with 1920 x 1080. I utilized postcss-pxtorem with a "rootValue" set to 192 for responsive scaling. The zoom is normal and functional on screens below 1920 pixels wide. However, on Android phones with 3840 x 2160 resolution, the page becomes distorted and only half of the content is visible. Here is the code snippet:

// design 1920 * 1080
function setRem() {
// Determine ratio of actual device width to design draft
const htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
const htmlHeight = document.documentElement.clientHeight || document.body.clientHeight;
const designRatio = 1920 / 1080;
const realRatio = htmlWidth / htmlHeight;

let baseSize = 192;
let scale = htmlWidth / 1920;
document.documentElement.style.fontSize = (baseSize * scale) + 'px';

// Adjust font size if width is sufficient but height is not
if (realRatio > designRatio) {
  document.documentElement.style.fontSize = (baseSize * scale) * (designRatio / realRatio) + 'px'
}
}

setRem();

window.addEventListener('resize', () => {
setRem();
});

Answer №1

The issue has been resolved, although not through REM, as the Android 5.0 system does not support the use of display: flex;

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

Is it possible to create a multi-page single-page application using Vue js SSR?

It may appear contradictory, but I struggle to find a better way to express it. When using vue server-side rendering, it seems you are limited to single page applications. However, for various reasons, I require an application with multiple real server-s ...

Dealing with asynchronous requests in Axios: A guide to solving the challenge

I'm working on a page named _id.vue in my Nuxt.js project: <template> <div class="wrapper"> <HeaderApp> <DivHeaderMenu> </DivHeaderMenu> </HeaderApp> <CenterContentDinamicFirmeni ...

I am experiencing issues with local storage getItem() function not functioning properly within NUXT JS

Currently working on creating a shopping cart using nuxt js. Successfully able to store the cart data in local storage, but facing difficulty in retrieving the data. Refer to the screenshots for more details: https://i.sstatic.net/X7dL9.png https://i.sstat ...

How to handle users with disabled Javascript? Considering redirection to alternate sites for users with script disabled?

I've dedicated today to strategizing the best approach for revamping our company's website, taking into consideration that less than 1% of web users have JavaScript disabled. Our management team strongly believes in ensuring that our website rem ...

Combining dynamic classes within a v-for loop

Here's my custom for loop: <div v-for="document in documents"> <span></span> <span><a href="javascript:void(0)" @click="displayChildDocs(document.id)" :title="document.type"><i class="fas fa-{{ d ...

What can I do to ensure that the selectInput choices in Shiny are easily accessible and visible to the user?

When running the code provided below, I encountered an issue where the options in the selectInput() were partially blocked by the bottom edge of the wellPanel(). This problem is illustrated in the image below. Users had to adjust the mouse wheel to see all ...

"Utilizing the Nuxt Vue Router afterEach Guard for Added Security

Is there a way to implement an afterEach handler in Nuxt that runs after route changes? While middleware can be used as a beforeEach, I'm struggling to find a solution for the afterEach hook. ...

What is the best way to transfer attribute values from multiple elements and paste them each into a separate element?

I have multiple elements with the tag <a class="banner2">. Each of these elements has a different URL for the background image and href value. <a href="#" target="_blank" class="banner2" style="background-image:url('<?php echo get_templat ...

VueJS does not refresh the list items when changes are made from components

Facing an issue with rendering an array from vuex using "v-for". The "player-card" component is not being displayed, however, the "td" solution is functioning correctly. Check out my example on JSFiddle. HTML: <div id="app"> <button ...

Tips for implementing a linear gradient on a bar graph using Highcharts

I'm trying to create a bar chart using highcharts, and I want to apply a linear gradient for the bar fill color. However, I am not sure how to set this up. Can anyone provide some guidance or ideas? Here is an example of what I'm hoping to achie ...

Unable to access the website's source code

It's frustrating when I can't view the source code of certain websites, such as this one: . When I try to right-click and select "View Source", only a portion of the code is displayed, which isn't the proper source code for the page. Alth ...

Trying to resolve w3 validator error and warning issues

While checking my HTML code using the W3 validator, I encountered an error and warning message: Line 21, Column 23: The ID menuItem was first used here. <li id="menuItem"><a href="#visit">Ten Places to Visit</a></li> ✉ Line 29 ...

Is it possible to pass props to a child component within router-view in Vue.js?

I have a dilemma with my three Views that rely on data from the parent - I only want one of these children to be displayed at a time. Parent The Parent component fetches API data and manipulates it, storing it as an array of objects in the data() object. ...

Tips for efficiently loading data into a vuex module only when it is required and addressing issues with async/await functionality

Is there a method to load all the data for a Vuex store once and only load it when necessary? I believe there is, but I am having trouble implementing it. I'm not sure if it's due to my misunderstanding of Vuex or Async/Await in Javascript promi ...

Customize checkbox and label using jQuery

I have a scenario where I have multiple checkboxes and corresponding labels. When the answer is correct, I want to change the background color of the selected checkbox and label. <input type="checkbox" id="a" class="check-with-label" /> <label fo ...

Is it possible to dynamically assign a CSS class to a DOM element during a drag operation while the mouse button is held down?

I am currently working on developing a unique pathfinder visualizer. My progress so far includes creating a grid of size 16x45 using the function below: export const drawBoard = () => { const boardContainer: HTMLDivElement | null = document.querySelec ...

Style the "focus" pseudo-class of an input element using Vue programmatically

Currently, I have been utilizing event listeners to manipulate the :focus pseudo-class of an input element: const element = document.getElementById("myElementID"); element.addEventListener("focus", (e) => { e.target.style.borderCo ...

Enhancing Security and Improving Performance with Subresource Integrity and Cache Busting Methods in

I am in the process of integrating Subresource Integrity and cache busting for my application's static assets like stylesheets and JavaScript files. Currently, I am using PHP with Twig templates. While I am aware of tools available for generating has ...

Fluid Bootstrap Container Experiencing Alignment Issues with Rows when CSS Height Property set to 100%

My Bootstrap container has a fluid width and I'm trying to align three rows within a sidebar to sit at the top, middle, and bottom. I came across this demo in the Bootstrap documentation which shows how to do it for full-width layout, but I need it fo ...

Customizing Bootstrap Navbar: Ensuring the External Search Bar is displayed correctly within the expanded navbar

In my Bootstrap 5 navbar, I have a search bar, notifications dropdown, and collapsible buttons. How can I ensure that the search bar is visible in the expanded version of the navbar and hidden when the navbar is collapsed, while keeping the notifications d ...