CSS定位基线
我希望下拉菜单与上面的 Btn1-2 和 Btn3 具有相同的基线级别,但在单元格内。基本上和现在的情况相反。我缺少什么?谢谢
<table style="width:100%">
<tr style="border:1px solid #000">
<td>
<div style="position:relative">
<input type="button" value="Bt1" />
<input type="button" value="Bt2" />
<div style="position:absolute; top:0; right:0;">
<input type="button" value="Btn3" /> <br />
<select>
<option>Hello</option>
</select>
</div>
</div>
</td>
</tr>
</table>
I would like to have the dropdown at the same baseline level of Btn1-2 and Btn3 above, but within the cell. Basically the opposite as what it is now. What am I missing? Thanks
<table style="width:100%">
<tr style="border:1px solid #000">
<td>
<div style="position:relative">
<input type="button" value="Bt1" />
<input type="button" value="Bt2" />
<div style="position:absolute; top:0; right:0;">
<input type="button" value="Btn3" /> <br />
<select>
<option>Hello</option>
</select>
</div>
</div>
</td>
</tr>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该这样做:
为两个
div
设置float
。这是演示: http://jsfiddle.net/naveed_ahmad/DnWWy/That's how you should do this:
Set
float
for the twodivs
. Here is the demo: http://jsfiddle.net/naveed_ahmad/DnWWy/更改 div 样式:position:absolute;定位:相对;这会将其保留在细胞内。
Change the div style from position:absolute; to position:relative; which will keep it inside the cell.
你可以试试这个。
You can try this one.