gpt4 book ai didi

html - 绝对定位按钮未定位在其父 DIV 中

转载 作者:搜寻专家 更新时间:2023-10-31 22:33:53 24 4
gpt4 key购买 nike

在下面的代码中,我将输入按钮添加到 leftPane div。
这里我有两个 div's/左 80% 和右 20%。
现在我想将此按钮垂直放置在左 Pane 的中间和右侧。
但是当我设置 'right:0;' 时它转到浏览器的右侧,而不是左 Pane 的右侧。
为什么?

<body style="overflow:hidden;">

<div style="background: #ff0000; position: fixed; top:0; left:0; width:100%; height:100%;">
<div id="leftPage" style="width:80%; height:100%;background:#00ff00; float:left;text-align:center;">
<img src="http://fc07.deviantart.net/fs45/f/2009/106/c/1/HD_Nature_Wallpapers_by_CurtiXs.jpg" alt="test" style="max-width:90%; max-height:90%;"/>
<input type="submit" value="Next" style="width:40px;height:70px;position:absolute;top:50%;right:0;"/>
</div>
<div id="rightPane" style="width:20%; height:100%;background:#0000ff; float:left;">
<div id="commentBox" style="background:#dddddd; width:90%; height: 50px;">
<input type="text" placeholder="Enter here..." />
</div>
</div>
</div>
</body>

最佳答案

您需要有父级 <div style="position: relative;">否则你的绝对定位默认为你的 <body>

为了澄清,设置#leftPage相对定位。

关于html - 绝对定位按钮未定位在其父 DIV 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8184185/

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