gpt4 book ai didi

css - 使用位置 :absolute 将 ionic 标题居中

转载 作者:行者123 更新时间:2023-11-28 02:03:10 25 4
gpt4 key购买 nike

我是 Ionic Framework 的初学者。最近我在导航栏的左侧建立了一个带有滑动后退按钮的页面。这会将标题向右移动一点:(我在标题中添加了红色背景来说明这一点)

不使用position:absolute:

enter image description here

为了使标题居中,我添加了以下 CSS 代码:

ion-title {
font-weight: bold;
position: absolute;
top: 0;
left: 0;
padding: 0 90px 1px;
width: 100%;
height: 100%;
text-align: center;
background-color: red;
}

有效:

使用position:absolute:

enter image description here

问题是标题现在“覆盖”了向后滑动的按钮,导致无法点击该按钮。

有什么解决办法吗?提前谢谢你。

最佳答案

尝试向后退按钮添加 position:relative 和一些 z-index 值...

我已经创建了一个工作片段来说明您的问题

div {
position: relative;
}

ion-title {
font-weight: bold;
position: absolute;
top: 0;
left: 0;
padding: 0 90px 1px;
width: 100%;
height: 100%;
text-align: center;
background-color: red;
box-sizing: border-box;
}

button {
width: 20px;
height: 20px;
background: green;
position: relative;
z-index: 99;
}
<div>
<button></button>
<ion-title>About</ion-title>
</div>

关于css - 使用位置 :absolute 将 ionic 标题居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49190764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com