菜鸟教程小白 发表于 2022-12-11 16:45:14

ios - 在 iOS 设备上运行时,Ionic bar-header 未居中


                                            <p><p>我正在使用 Ionic 构建适用于 Android 和 iOS 的应用。<br/>
我在 View 中使用 <code>bar-header</code> 作为标题:</p>

<pre><code>&lt;ion-view view-title=&#34;Home&#34; class=&#34;tab-home&#34;&gt;
    &lt;ion-content class=&#34;padding&#34;&gt;
      &lt;div class=&#34;bar bar-header bar-positive&#34;&gt;
            &lt;div class=&#34;h1 title&#34;&gt;The European Experience&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&#34;bar bar-subheader bar-stable&#34;&gt;
            &lt;h2 class=&#34;title&#34;&gt;Companion App&lt;/h2&gt;
      &lt;/div&gt;
      &lt;div class=&#34;content has-header padding&#34;&gt;
            ...
      &lt;/div&gt;
    &lt;/ion-content&gt;
&lt;/ion-view&gt;
</code></pre>

<p>当使用 <code>ionic serve -l</code> 在我的浏览器中显示时,标题正确显示:</p>

<p> <a href="/image/p7oKi.png" rel="noreferrer noopener nofollow"><img src="/image/p7oKi.png" alt="ionic lab display"/></a> </p>

<p>在真正的 Android 设备上运行时,它也能正常工作:
<a href="/image/nyv8T.png" rel="noreferrer noopener nofollow"><img src="/image/nyv8T.png" alt="run on Android"/></a>
但是当我在 iOS 设备(物理设备或模拟器)上运行应用程序时,标题不是垂直居中的:</p>

<p> <a href="/image/S7wHr.jpg" rel="noreferrer noopener nofollow"><img src="/image/S7wHr.jpg" alt="run on iPhone"/></a>
我尝试添加 CSS 以明确指定 <code>vertical-align</code> 或 <code>text-align</code>,但没有成功。</p>

<h2>什么可以解释这个问题?我怎样才能在这个标题中居中标题?</h2></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这种问题很常见,具体取决于您使用的 Ios/Ionic 版本,
您是否尝试使用标签?
<a href="http://ionicframework.com/docs/api/directive/ionHeaderBar/" rel="noreferrer noopener nofollow">ion-header-bar</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 iOS 设备上运行时,Ionic bar-header 未居中,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/37862015/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/37862015/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 iOS 设备上运行时,Ionic bar-header 未居中