search
HomeWeb Front-endHTML TutorialThe same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose

img has display:block in advance. Using px control, both Android and ios are normal. Using percentage, Android is normal, iOS is deformed, and the parent div will be enlarged. I removed the height of the img, and the height of the img will adapt to the parent div, which is available on both Android and iOS.
Can anyone tell me why this is? ?


Reply to discussion (solution)

.img-responsive { display: block; max-width: 100%; height: auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.

.img-responsive { display: block; max-width: 100%; height: auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

Since you are on a mobile device
then use a div to set the background image to handle stretching and deformation

Since you are on a mobile device
then use a div to set the background image To deal with the stretch deformation



I removed the percentage of the img. It will automatically adapt to the height of the parent div. I have removed it.

What I want to know most is why the height cannot be controlled using percentage. It is completely impossible under ios, and px can be used anywhere.
----------------------------------------------- -------------------------------------------------- ------


.img-responsive { display: block; max-width: 100%; height: auto; }


Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

This is feasible, the width is adaptive! Dynamically adjust the height beyond the module you want overflow:hidden;



.img-responsive { display: block; max-width: 100%; height : auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

This is feasible, the width is adaptive! The height is dynamically adjusted, if it exceeds the module you want overflow:hidden;
If it is not exceeded, there is no height at all. . . *{overflow: hidden;} has been used,
should be added?

max-width:100%;



img has been displayed:block in advance. Using px control, both Android and ios are normal. Using percentage, Android is normal, iOS is deformed, and the parent div will be enlarged. I removed the height of the img, and the height of the img will adapt to the parent div, which is available on both Android and iOS.
Can anyone tell me why this is? ?



Post the problematic code directly




.img-responsive { display: block; max-width: 100%; height: auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

This is feasible, the width is adaptive! The height is dynamically adjusted, if it exceeds the module you want overflow:hidden;
If it is not exceeded, there is no height at all. . . *{overflow:hidden;} has been used, and
should be added?


In view of *{overflow: hidden;} this kind of code, I think the author has little understanding of the web field!
So I will go directly to a small demo I made,
http://qianjia.com/demo/co.special
You can adjust the browser size on firefox and then use firebug to look at the code. .
No matter how much you say, it won’t help. I suggest that after understanding the basic knowledge of w3school, the author should dabble in more front-end knowledge.






.img-responsive { display: block; max-width: 100%; height: auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

This is feasible, the width is adaptive! The height is dynamically adjusted, if it exceeds the module you want overflow:hidden;
If it is not exceeded, there is no height at all. . . *{overflow:hidden;} has been used, and
should be added?


In view of *{overflow: hidden;} this kind of code, I think the author has little understanding of the web field!
So I will go directly to a small demo I made,
http://qianjia.com/demo/co.special
You can adjust the browser size on firefox and see the code, and then use firebug to look at the code. .
No matter how much you say, it won’t help. I suggest that the poster should dabble in more front-end knowledge after understanding the basic knowledge on w3school.


On the mobile phone, the company uses myeclipse to develop the web page and it cannot be adjusted

I have another question to ask you

I am currently using jquery mobile. Regarding web development on mobile phones, the only information available now is from W3C and various fragments from Baidu. Is there any systematic information that I can study?






.img-responsive { display: block; max- width: 100%; height: auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

This is feasible, the width is adaptive! The height is dynamically adjusted, if it exceeds the module you want overflow:hidden;
If it is not exceeded, there is no height at all. . . *{overflow: hidden;} has been used,
should be added?


In view of *{overflow: hidden;} this kind of code, I think the author has little understanding of the web field!
So I will go directly to a small demo I made,
http://qianjia.com/demo/co.special
You can adjust the browser size on firefox and see the code, and then use firebug to look at the code. .
No matter how much you say, it won’t help. I suggest that the poster should dabble in more front-end knowledge after understanding the basic knowledge on w3school.


On the mobile phone, the company uses myeclipse to develop web pages, and it cannot be adjusted

firefox firebug This is the most basic web development and testing tool,
If it is For mobile phones, it is recommended to use: chrome plug-in Responsive Web Design Tester,








.img-responsive { display: block; max-width: 100%; height: auto; }

The same style and the same percentage can be used to control the height of the img under Android, but why can't it be done under iOS? _html/css_WEB-ITnose
Will this still cause problems? Just copy it and try it.



Do you want the height to be adaptive? That doesn't work, I've tried it.

This is feasible, the width is adaptive! The height is dynamically adjusted, if it exceeds the module you want overflow:hidden;
If it is not exceeded, there is no height at all. . . *{overflow: hidden;} has been used,
should be added?


In view of *{overflow: hidden;} this kind of code, I think the author has little understanding of the web field!
So I will go directly to a small demo I made,
http://qianjia.com/demo/co.special
You can adjust the browser size on firefox and then use firebug to look at the code. .
No matter how much you say, it won’t help. I suggest that the poster should dabble in more front-end knowledge after understanding the basic knowledge on w3school.


For the mobile version, the company uses myeclipse to develop web pages, and it cannot be adjusted

firefox firebug is the most basic web development and testing tool.
If it is on mobile phone, it is recommended to use: chrome plug-in Responsive Web Design Tester,




I can use firebug. I just used the mobile version, thank you for your advice
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

HTML's Purpose: Enabling Web Browsers to Display ContentHTML's Purpose: Enabling Web Browsers to Display ContentMay 03, 2025 am 12:03 AM

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

Why are HTML tags important for web development?Why are HTML tags important for web development?May 02, 2025 am 12:03 AM

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software