The height of the image is equal to the height of the phone/tablet - functioning correctly only in Chrome

, I'm currently fine-tuning my portfolio website with the help of responsive and adaptive design using mobile_detect.php. The challenge lies in getting the codes to align perfectly for desktop and handheld devices. To simplify testing on desktop before venturing into mobile troubleshooting, I recommend downloading the "User-Agent Switcher for Chrome" extension for Chrome from https://chrome.google.com/webstore/detail/djflhoibgkdhkhhcedjiklpkjnoahfmg. For Firefox, grab the "User Agent Switcher" extension from https://addons.mozilla.org/hu/firefox/addon/user-agent-switcher/. My goal is to ensure that my website looks consistent across both mobile and desktop versions on Chrome and Firefox browsers. Here's a glimpse at the HTML structure:
To address image resizing on mobile and tablet screens, I've included the following JavaScript snippet in js/scripts-mobile.js: // Vertical image resize for Mobile/Tablet Window height $(document).ready(function(){ function horgalleryImagesSize(all) { windowHeight = $(window).height(); if (all) { $('.horgallery .images li').css({'max-height': windowHeight}); } } $(document).ready(horgalleryImagesSize); // Trigger calculation $(window).resize(horgalleryImagesSize); // Trigger Resize REAL-TIME }); And to style these elements accordingly, here are snippets from css/mobile.css: .horgallery .images li { float: none; clear: both; display: block; position: relative; } .horgallery .images img { float: none; max-width: 100%; max-height: 100%; } .horgallery .images li { padding: 0 0 30px 0; text-align: center; } Despite my efforts, there are some challenges. While my design shines on Chrome, Firefox displays images at full screen width but cuts off parts exceeding the screen height. Android mobile browsers encounter issues with image resizing as well. I aim for vertical images to never surpass the screen height and hope to introduce swipe functionality later on. Genymotion emulator has been helpful for testing on Android 4.3. Merging aspect ratios with real-time resizing remains a hurdle due to my lack of expertise in JavaScript. Santiago's suggestion brought minor relief on native Android browsers, while Chrome excelled and Firefox fell short. Safari compatibility remains unexplored. It seems I must make peace with Firefox's behavior for now, while contemplating ways to calculate image aspect ratios for optimal resizing. Thanks to all who have contributed!

Answer №1

Consider replacing the maximum height with just height;

$('.horgallery .images li').css({'height': windowHeight});

Additionally, it seems like this may not be necessary:

$(window).resize(horgalleryImagesSize); // Trigger Resize REAL-TIME

Update:

You might want to experiment with CSS3 image attributes such as cover, contain, etc.

Also, make sure to update the

$('.horgallery .images li').css({'height': windowHeight});

every time the orientation changes (I believe it was onorientationchange event or something similar).

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

Engaging Bootstrap blocks for interactive designs

I am facing an issue with a block on my page. The structure of the block is as follows: <!-- Interactive Block --> <div class="block"> <!-- Interactive Title --> <div class="block-title"> ...

Nativescript: Getting ready to set up the "Install Google Repository" option

After working on my project for 4 hours, I found myself stuck at the "Preparing Install Google Repository" stage. I recently installed the nativescript-plugin-firebase plugin and now I can't seem to build my project properly. Interestingly, everything ...

"Showcasing MongoDB information on a webpage using Node.js and HTML

We have stored worker information in MongoDB. Now, how can we display that information on an HTML home page? Here is the code I used to save the data: //routes.js var Employee = require('../app/models/employee'); app.post("/addEmployee", (req ...

What is the process for transforming raw text data into json format?

After receiving a response from the API mentioned below, I have been attempting to transform the data into a JSON array without much success. found=100 items[0].Detail.Address=192.168.1.4 items[0].Detail.Type=CGI items[0].Device= items[0].Level=0 items[0]. ...

Prevent the combining of 3D shapes during rotation with three.js

When I use translateZ to place 3D objects on top of each other, they look fine when paused. However, once I rotate the scene, these objects start merging together. Can anyone provide a solution to eliminate this issue? The black block is placed on top of ...

I have difficulty getting divs to float the way I want them to

I have a total of 5 divs inside one main div, and I want to arrange them so that 2 are floating on the left and the remaining 3 are floating on the right: .container { height: 400px; border: 1px solid black; } .first, .second, .third, .fourth, .fift ...

Set the value of one email input to another email input in AngularJS

I'm having trouble trying to link an email input field to another in angularjs without success. Here is what I have attempted so far: <div class="row-fluid"> <div class="control-group span12"> <label for="email">Email</labe ...

Changing Three.js from mouse interaction to a random movement pattern

Recently, I came across this interesting website with a background that lights up depending on the movement of your mouse. I was wondering if there is a way to make that illuminated spot move around on its own. If you want to see how it looks, check out th ...

Unable to successfully add element to array using UIKit modal in vuejs

On my webpage, I have a table that showcases an array of "currency" objects: <tbody> <tr v-for="currency in currencies" v-bind:key="currency.Name"> <td class="uk-width-medium">{{currency.Enabled}}</ ...

How to interrupt a JQuery animation and restart it from the middle?

Currently, I am tackling my first JQuery project and facing a challenge. As the user mouseleaves the .container, the animation does not reset but continues as if they are still within it. My goal is to have the animation revert in reverse if the user decid ...

Guide on defining keyframes in a CSS animation based on a specific property value

In CSS animations, keyframes are defined using percentages to determine their position: @keyframes foo { 0% { ... } 50% { ... } 100% { ... } } I'm working on a basic animation where an object smoothly moves across the screen. However, I ...

executing a pre-existing executable file within a web browser or XAML Browser Application (

Currently, I have an application (let's call it exe1) provided by the supplier of our instruments that I would like to integrate into my existing application. Instead of rewriting exe1 from scratch, I am considering embedding it using something like a ...

What are the different HTTP Methods supported by AJAX?

Considering that HTTP supports a variety of methods such as GET, PUT, POST, DELETE (and others like PATCH, HEAD, OPTIONS, etc.), I am pondering over which of these methods an AJAX request typically utilizes. Is there an option to specify which method we ...

Adjust the placement of a dropdown menu placed within a table

I have successfully implemented a sticky table header, but I am encountering an issue with the select element integrated into my table: View before scrolling the table View after scrolling the table As you can see, the select element overlaps with the t ...

The navigation bar fails to respond when clicked on mobile devices

Calling all developers! I need a helping hand to tackle an issue that's holding me back from completing this website. Can someone please take a look at on their smartphone browser and figure out why the responsive menu icon isn't working when cl ...

The Jquery ajax page is redirecting automatically when a post request is made

Encountering an issue while attempting to upload multiple files through AJAX, as the process redirects to a blank page displaying only the names of the uploaded files. Here is the HTML tag: Below is the JavaScript function: function upload(){ var proje ...

Transforming the input button into images

I'm new to JavaScript and I'm looking to change the show button and hide button to images instead. The show button image should be different from the hide button image. Can anyone guide me on how to achieve this? Click here for reference $( ...

Does .NET MVC provide the necessary separation of HTML/CSS/JS for my project?

Currently, I am collaborating with my ASP.NET development team in an effort to improve the quality of our HTML output. We are facing challenges due to ASP.NET's tendency to insert JavaScript directly into the page, creating dependencies on JS for form ...

Having difficulty with androiddebugCompileTest and encountering errors while trying to build with Gradle

*# Here is the build.gradle file for my app module #* apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.mytech.wv" ...

How can I extract values from an array stored in an external text file using Jquery?

I'm attempting to retrieve an error message from an external file called errors.txt. The contents of errors.txt are as follows: var data = { 'errors': [{ "code": "9999", "message": { row: 1, ...