Looking for a media query fix for specific mobile browsers

Managing a simple single-page web application is proving challenging, as I strive to optimize its appearance across various devices.

The layout is stable on:

  • Acer Laptop(1366 x 768) on Chrome, Firefox, and Opera
  • HTC One X(720 x 1280) on Chrome, Opera, Firefox (few bugs)
  • HTC One(1080 x 1920) on Chrome and Firefox (few bugs), not tested on Opera

However, the layout is distorted on:

  • HTC Default Browser(tested on HTC One X/One)
  • UC Browser (on HTC One X)
  • Safari on iPhone 4S (up to date)
  • Possibly IE, but no confirmation yet.

Distorted here refers to elements being misaligned with incorrect sizes, as if the main layout is disregarded.

Interestingly, Chrome and Firefox display correctly. Although Firefox encounters issues with my JQuery functionality.

You can check out the app itself by following this link: here

So, here's my dilemma:

How do I rectify the layout discrepancies in browsers listed under distortion? Despite extensive online research, many proposed solutions leveraging media queries have failed to offer a universal fix.

I'm currently employing the CSS snippet below, which successfully renders the layout on the mentioned devices and browsers:

@media only screen and (max-width: 2000px) {
    //CSS content here
}

@media only screen and (min-width: 320px) and (max-width: 767px), 
       only screen and (min-device-width : 320px) and (max-device-width : 480px)/*iphone 2g-4s*/ {
    //Additional CSS content for specific device width ranges
}

@media only screen and (min-width: 320px) and (max-width: 767px) and (orientation: landscape),
       only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) {
    //Additional CSS content for landscape orientation
}

Answer №1

If you don't have a specific need for Flexbox features that cannot be replicated using other methods, it's best to avoid using Flexbox. And if you do use prefixes, make sure to include all necessary prefixes for each property.

@media only screen and (max-width: 2000px) {
  /* CSS code here */
}

@media only screen and (min-width: 320px) and (max-width: 767px), only screen and (min-device-width: 320px) and (max-device-width: 480px) {
  /* Additional CSS code for specific screen sizes */
}

@media only screen and (min-width: 320px) and (max-width: 767px) and (orientation: landscape), only screen and (min-device-width: 320px) and (max-device-width: 480px) and (orientation: landscape) {
  /* More CSS code for landscape orientation */
}

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 there a way to ensure that the height of my images matches exactly with its width?

Is there a way to ensure that the height of my images always matches their width? I need the height of the images to dynamically adjust and match the width, even when the window is resized. For example, if the image width is 500px, the height should also ...

Animation for Bootstrap dropdowns fails to display in Internet Explorer and Firefox browsers

As I embark on creating my debut website using Bootstrap, I have incorporated a special CSS code snippet in my custom.css file to add an eye-catching animation to the dropdown menu in the navigation bar: .open > .dropdown-menu { -webkit-transform: sc ...

Converting JSON array to a String and back to JSON in an Android application

Recently, I've been working on sending post data to my local PHP server. To make it easier to process the data later in PHP, I decided to format the post data as JSON. Using "Namevaluepairs", I converted my JSON array to a string and ended up with the ...

Adding extra space on a Bootstrap 4 flex container with full height

I need help creating a fixed div with 100% height and vertically centered alignment using Bootstrap 4. I've achieved everything except adding padding. When I try to add padding to the child div, the content overflows off the screen. I even attempted ...

Launch current screen inside a jquery dialog box

When attempting to open an existing aspx page within a jQuery dialog, I noticed that the CSS of the parent screen is being overridden by the dialog box. Is there a way to prevent this without making changes to the existing screen? If there are any altern ...

How to configure d3.js on an Android device

I am interested in creating a collapsible tree visualization using d3.js. I came across a helpful tutorial on . However, I am unsure of how to begin (installing d3.js) and integrating it into my android applications. Are there any reliable resources or re ...

The sdkmanager consistently provides the same output, regardless of the arguments supplied to it

After downloading the SDK Tools for Windows and attempting to run it, I encountered a persistent issue. No matter which command I used (sdkmanager, sdkmanager --list, sdkmanager --version, sdkmanager asdoifjasodjfoas), the same block of text was always pri ...

Running NodeJS on mobile devices such as IOS and Android

Perhaps this question may sound naive, as I don't have much experience with server-side operations. I am currently developing an Angular web application that will utilize nodeJS on the backend. I want to have the server (Node.exe) installed directly ...

Enhancing button images with gradient effects on hover

I'm currently working on adding a color gradient effect to a PNG graphic used as a button. I specifically want the color gradient to appear only when the user hovers over the image, and not just for background images like most solutions seem to provid ...

Issue with fullcalendar: difficulty displaying events using ajax after clicking 'previous' or 'next' button

I am currently working on creating a calendar using fullcalendar. To retrieve data for the month, I make an external ajax request. Here are the key variables I utilize to render the fullcalendar: eventsJsonArray - used to load all events for the month ...

Tips for starting JavaScript on Materialize 1.0

I need some help with initializing a materialize component using JavaScript. My understanding of JS is lacking, but I have had success using jQuery. Specifically, I am looking to use the Collapsible component. <ul class="collapsible"> <li> ...

Optimizing CSS for smartphones and tablets

Using the standard CSS for writing content will ensure compatibility with all mobile devices. In my current project, I have developed a mobile application and utilized the following CSS code to display some data: <div style="float: left; width: 90%; ma ...

What is the best way to place a list below another list, which also includes a sub-list, in a responsive website design without causing the main lists to overlap

I have lists containing sub-lists, and I want to ensure that when the window screen is shrunk, the lower lists do not overlap the sub-lists of the upper ones. HTML markup - <div class="row-fluid"> <ul> ...

I encountered a Java null exception in my code

I'm encountering a Java null error in my profile fragment while trying to implement an online status feature. Can someone assist me with resolving this issue? I have a deadline to finish this task today. Below is my profile fragment along with the log ...

Poor performance in OpenGL on Android Gingerbread has been a common issue among

I've been developing a video game for Android using OpenGL 1.0. My development process was guided by the following tutorial: I have created a demo that runs smoothly and efficiently (capped at 30 FPS) on my current device: HTC Sensation (Android 4.0 ...

What is the best way to execute TypeScript programs on an Android device?

Is there a way to execute TypeScript programs on an Android phone? Are there any offline apps specifically designed for running TypeScript programs on Android devices? ...

Is there a way to retrieve a NinePatch image from "disk" and transform it into a NinePatchDrawable?

My goal is to access multiple NinePatch images from either the SD card or assets without them being compiled. Unfortunately, I have been unable to locate any constructors or factories to assist with this task. I even attempted to use the NinePatch tool sou ...

What is the best way to deactivate div elements once an overlay has been applied to them?

My goal is to place an overlay on my form to prevent users from accessing the content. Even though I have added an overlay, users can still interact with input fields. How can I prevent that? .overlay { background: rgba(0, 0, 0, .75); text-align: ce ...

What is the ideal framerate for smooth animation?

I'm looking to add a snow animation using JavaScript. I currently have it running at 200ms which is decent but not smooth enough. Would changing the interval to 20ms make it more fluid, or would it be inefficient and strain the CPU? window.setInterva ...

Are static final classes used to implement abstract fields?

As I work on developing unique custom color palettes for my Android app, I initially took this approach: public class Theme { public static final class DARK { final static int POSITIVE_GREEN = Color.rgb(0, 200, 0); final static int NE ...