<span id="Label3"></p><p><p>Reproduced in the Efe blog, this is a very valuable article, do not run the basic mobile will encounter the issue mentioned in this Article.</p></p><p><p></p></p><p><p>Mobile business development, under IOS often have fixed elements and input boxes (input elements) exist at the same time. however, fixed elements in the case of a soft keyboard aroused, there will be a lot of inexplicable problems. This article provides a simple fixed layout scheme with input Boxes.</p></p><p><p></p></p><p><p></p></p>Fixed + Input bug phenomenon under iOS<p><p>Let us first give a chestnut, the most intuitive explanation of the phenomenon of this BUG. The regular fixed layout may use the following layout (only the schematic code below):</p></p> <table> <tbody> <tr> <td class="code"><pre><span class="line"><span class="tag"><<span class="title">Body<span class="attribute">class=<span class="value">"layout-fixed" ><br><span class="line"><span class="comment"><!--fixed-positioned head-to-<br><span class="line"><span class="tag"><<span class="title">Header><br><span class="line"><br><span class="line"><span class="tag"></<span class="title">Header><br><span class="line"><br><span class="line"><span class="comment"><!--areas that can be scrolled--<br><span class="line"> <span class="tag"><<span class="title">Main><br><span class="line"><span class="comment"><!--content here ...-<br><span class="line"><span class="tag"></<span class="title">Main><br><span class="line"><span class="line" , <br> <span class="line"> <span class="comment"><!--the bottom of fixed positioning-- <br> <span class="tag" <span><<span class="title">footer> <br> <span class="tag" <span><<span class="title">input <span class="attribute">type=<span class="value"> "text" <span class="attribute">placeholder= <span class="value"> "Footer ..."/> <br> <span class="line"> <span class="tag"><<span class="title">button <span class="attribute">class=<span class="value"> "submit" > Submit <span class="tag"></< Span class= "title" >button> <br> <span class="line"> <span class="tag"></<span class="title"> Footer> <br> <span class="line"><span class="tag"></<span class="title">body> <br> </span> </span> </span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> </span></span></span></span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></pre></td> </tr> </tbody> </table><p><p>The corresponding styles are as Follows:</p></p> <table> <tbody> <tr> <td class="code"><pre><span class="line"><span class="tag">Header<span class="tag">Footer<span class="tag">Main<span class="rules">{<br><span class="line"><span class="rule"><span class="attribute">Display<span class="value">Block<br><span class="line"><span class="rule">}<br><span class="line"><br><span class="line"><span class="tag">Header<span class="rules">{<br><span class="line"><span class="rule"><span class="attribute">Position<span class="value">Fixed<br><span class="line"><span class="rule"><span class="attribute">Height<span class="value"> <span class="number">50px;<br><span class="line"><span class="rule"><span class="attribute">Left<span class="value"> <span class="number">0;<br><span class="line"><span class="rule"><span class="attribute">Right<span class="value"> <span class="number">0;<br><span class="line"><span class="rule"><span class="attribute">Top<span class="value"> <span class="number">0;<br><span class="line"><span class="rule">}<br><span class="line"><br><span class="line"><span class="tag">Footer<span class="rules">{<br><span class="line"><span class="rule"><span class="attribute">Position<span class="value">Fixed<br><span class="line"><span class="rule"><span class="attribute">Height<span class="value"> <span class="number">34px;<br><span class="line"><span class="rule"><span class="attribute">Left<span class="value"> <span class="number">0;<br><span class="line"> <span class="rule"><span class="attribute"><span class="attribute">right:<span class="value"> <span class="number">0; <br> <span class="line"> <span class="rule"><span class="attribute">bottom:<span class="value"> <span class="number">0; <br> <span class="line"><span class="rule">} <br> <span class="line"> <br> <span class="line"><span class="tag">main <span class="rules">{<br> <span class="line"> <span class="rule"><span class="attribute">margin-top: <span class="value"> <span class="number">50px; <br> <span class="rule" <span><span class="attribute">margin-bottom:<span class="value"> Span class= "number" >34px; <br> <span class="rule" <span><span class="attribute">height:<span class="value"> <span class="number">2000px <br> <span class="line"> <br> </span> </span> </span> </span> </span> </span> </span> </span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></pre></td> </tr> </tbody> </table><p><p>And then it looks like the following. When you drag the page header and footer have been positioned in the corresponding position, visual no Problem.</p></p><p><p></p></p><p class="caption"><p class="caption">Fixed positioning</p></p><p><p>But then the problem comes! If the bottom input box soft keyboard is aroused later, sliding the page again, you will see as Shown:</p></p><p><p></p></p><p><p>We see fixed positioned elements following the page scrolling ... the fixed property is invalid!</p></p><p><p>What is this for? Simple explanation: after the > <strong>soft Keyboard is aroused, the fixed element of the page will be invalidated (that is, it cannot be floated or it can be understood as absolute positioning), so when the page is more than one screen and scrolling, the invalid fixed element will follow the Scroll. </strong></p></p><p><p>This is the fixed element and input box bug on iOS. This is not limited to <code>type=text</code> the input box, usually the soft keyboard (such as Time-date selection, select selection, etc.) are aroused, will encounter the same problem.</p></p>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service