Why does the width of my image appear differently on an iPhone compared to other devices?

I recently encountered an issue with the responsiveness of an image on my website. While it displayed correctly on Android and desktop devices, the image appeared distorted on iPhones as if the CSS width attribute was not applied properly. This problem specifically occurred on a web app page which can be viewed online at:

On Android:

https://i.stack.imgur.com/a3Opn.jpg

iOS: https://i.stack.imgur.com/D5FdA.jpg

This is a snippet of my HTML code:

<Row id='client' className='backgroundClient'><img src="/images/bandeauClient.png" /></Row>
       <Row>
    <Col className="paraClientFaq" xs={12} s={12} md={12}><h1><strong>Clients :</strong>{''}une nouvelle façon de remercier !</h1></Col>
           <Col className="paraClientTexteFaq" xs={12} s={12} md={12}><p>Vous avez de - en - de monnaie dans vos poches et la COVID-19 ne vous incite pas à en avoir ! Les restaurateurs n'acceptent que très rarement l'arrondi de l'addition sur le TPE ! Scannez le QR code Tipourboire présent sur votre addition, et donnez le montant de votre choix! Rapide, efficace et sécurisé sans être obligé de vous inscrire, vous aurez la garantie que votre pourboire digital arrivera à votre serveur ou encore à toute l'équipe si vous le désirez !</p></Col>
       </Row>
       <Row className="rowIconeClient">
           
           <Col md={2} s={6} xs={4} className="blocClient"><img className='img1' src="/images/greeting.png" /></Col>
           <Col md={2} s={6} xs={4}  className="blocClient"><img className='img2' src="/images/approved.png" /></Col>
           <Col md={2} s={6} xs={4}  className="blocClient"><img className='img3'src="/images/pouce.png" /></Col>
       </Row>

Below is a portion of the CSS related to this issue:

.FAQ .paraClientFaq{
    margin-top: 10%;
    margin-bottom: 3%;
    text-align: center;
    color: #f5a624;
}

.FAQ .paraClientTexteFaq{
    text-align: center;
    padding-left: 15%;
    padding-right:15%;
    font-size: 22px;
}


.FAQ .blocClient img{
    width:100%
}

.FAQ .rowIconeClient{
    text-align: center;
    justify-content: center;
    margin-top: 3%;
    margin-bottom: 5%;

}

.FAQ .paraIcone{
    color: white;
    margin-top:7%;
}

.FAQ .backgroundClient img{
    width: 100%;
}

Answer №1

One way to ensure proper display of the image is by using the CSS property object.fit: contain.

By utilizing the object-fit property, you can dictate how the image appears based on the screen size.

After reviewing your link, I tested this solution on both Chrome and Firefox:

.FAQ .backgroundClient img{
    width:100%;
    object-fit: contain;
}

Another option is to set the max-width to 100% (restricting resizing beyond this point) while setting height to auto:

.FAQ .backgroundClient img{
        max-width:100%;
        height: auto;
 }

https://i.stack.imgur.com/IezNk.png

If this answer was helpful in resolving your issue, please consider upvoting or accepting it. Thank you.

Answer №2

Consider applying a style to your image using object-fit: contain;

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

A guide on how to associate data in ng-repeat with varying indices

Here is the data from my JSON file: var jsondata = [{"credit":"a","debit":[{"credit":"a","amount":1},{"credit":"a","amount":2}]}, {"credit":"b","debit":[{"credit":"b","amount":3},{"credit":"b","amount":4},{"credit":"b","amount":5}]}, {"credit":"c","debi ...

I keep encountering a network error whenever I try to refresh the page. What could be causing this issue? (

Whenever I make a GET request to an API using useEffect(), everything works fine when I navigate from the homepage to the page. However, if I refresh the page at http://localhost:3000/coins/coin, I encounter an error message saying "Unhandled Runtime Error ...

Incorporating XMLHttpRequest in my React Typescript App to trigger a Mailchimp API call, allowing users to easily sign up for the newsletter

My website needs to integrate Mailchimp's API in order for users to subscribe to a newsletter by entering their email into a field. I am looking to implement this without relying on any external libraries. To test out the functionality, I have set up ...

Challenges with presenting Material UI React paper component in a nested grid layout

I'm stuck on an issue with my code that involves a nested grid and a paper component. Here's the snippet: import React from 'react'; import logo from './logo.svg'; import './App.css'; import { Container, AppBar ...

What a great method to execute a button click within the same button click using jQuery!

Here's an example of code that attempts to make an ajax call when a user clicks a button. If the ajax call fails, the button should be reclicked. I've tried this code below, but it doesn't seem to work. $("#click_me").click(function(){ ...

Formik UI validation for Material-UI React radio buttons

I have successfully implemented formik with Material UI React form components, particularly the TextField component. Here is the code snippet for reference: <TextField id="firstName" name="firstName" ...

Struggling to retrieve scope data within directive from controller in AngularJS

As a newcomer to AngularJS, I have utilized a service to retrieve data from the backend and received it in the controller. Now, my task is to parse these values and dynamically generate elements in a directive. However, when attempting to do so, I am encou ...

Error encountered when attempting to upload an attachment in Sharepoint, resulting in a

Whenever I attempt to upload multiple attachments to my list, I encounter a 'save conflict' error. It seems that Sharepoint is still processing the previous attachment when a new one is submitted. I believe that introducing a delay before sendin ...

Using JavaScript to Transmit URL

Imagine I have a URL similar to this: http://localhost:8000/intranet/users/view?user_id=8823 All I aim to achieve is to extract the value from the URL using JavaScript, specifically the user_id (which is 8823 in this instance), and transmit it through an ...

Utilizing Three.js to Upload Images and Apply Them as Textures

While attempting to upload an image via URL and set it as a texture, I encountered an issue. The error message THREE.WebGLState: DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Tainted canvases may not be loaded ...

How can I add information into a nested div element?

I encountered an issue when attempting to insert data into my block. The div structure is as follows: <div class="1"> <div class="2"> <div class="3"> <div class="4"></div> </div> ...

AngularJS postback method fails to trigger

Seeking assistance with my angularJS AJAX postback method. Below is the HTML code I have created: <html xmlns="http://www.w3.org/1999/xhtml" ng-app> <head runat="server"> <title></title> <script src="Scripts/angular.js ...

When using Inertia.js with Laravel, a blank page is displayed on mobile devices

Recently, I've been working on a project using Laravel with React and Inertia.js. While everything runs smoothly on my computer and even when served on my network (192.168.x.x), I encountered an issue when trying to access the app on my mobile phone. ...

``Incorporate images into a slideshow container with proper alignment

I'm currently using a jquery slideshow on my homepage with fading images, but I'm having trouble centering them. The images are all different sizes and they're aligning to the left instead of being centered. Here is the CSS code I've b ...

Is it possible to constantly retrieve data at one-second intervals in NextJS using getServerSideProps?

Is there a way to continuously fetch API data in NextJS using SSR (getServerSideProps) every second? This would involve the client making a request to the server every one second to receive the most up-to-date API data. Any suggestions? export const getS ...

Exploring the DOM in JavaScript: Searching for the final ancestor containing a specific attribute

Check out this example of HTML code: <div id="main1" data-attribute="main"> <div id="section2" data-attribute="subsection"> <div id="nested3" data-attribute="sub-subsection"> </div> </div> </div> <div id= ...

Issues persist while attempting to save sass (.scss) files using Atom on a Mac

When attempting to work with sass files, I encountered an error message every time I tried to save the file: Command failed: sass "/Users/bechara/Desktop/<path of the file>/test.scss" "/Users/bechara/Desktop/<path of the file>/test.css" Errno: ...

Dealing with null exceptions in Angular 4: Best practices

Hi there, I am encountering an issue with binding my model data to HTML fields where when I try to edit the data it returns an error saying "cannot read value of null". How can I resolve this? Here is the HTML code snippet: <div class="form-group"> ...

Utilizing SASS, JavaScript, and HTML for seamless development with Browser Sync for live syncing and

I've been on a quest to find a solution that covers the following requirements: Convert SASS to CSS Post-process CSS Minify CSS Move it to a different location Bundle all Javascript into one file Create compatibility for older browsers Tre ...

Vue is refusing to display information for a certain API call

Within my next component, I have the following structure: <template> <div class="home"> <div class="container" v-if="data" > <Card v-for="result in data" :img="result.links[0]&q ...