Why is iPhone not compatible with max-width: 100%?
P粉806834059
2023-09-02 17:24:50
<p>In my web browser, if zipped and on my Android phone, 100% works perfect. But not so on iPhone. </p>
<p>For images, I usually use max-width: 100%;, and if appropriate, width: 100%; or img-responsive. The image width is larger than 600px, so I set the width to 600px to control on larger devices. </p>
<pre class="brush:php;toolbar:false;"><section class='section20'>
<figure class="image">
<img src="images/user-content/1/20221003160546.jpg">
</figure>
</section></pre>
<p>CSS:</p>
<pre class="brush:php;toolbar:false;">.section20 .image,
.section20 img {
width: 600px !important;
max-width: 100% !important;
}</pre>
<p>It makes no difference whether you add !important or not. The formatting editor is CKEditor 5. It's very strict in how it handles classes in your code. If you add a custom class in code view, it will remove it from the figure when you return to the formatted editor view. </p>
<pre class="brush:php;toolbar:false;"><figure class="image">
<figure class="image my-custom-class"></pre>
<p>custom-class will be deleted. </p>
Don't hardcode width and height. Use rem or vw/vh (recommended).
means that the height of this element is equal to 100% of the viewport height.
Check your selectors.
Specify the
img
wrapper using.section20 .image
to stay at600px
and will not change withmax-width: 100%;
while resizing.Use
.image img
instead.