gpt4 book ai didi

html - 如何垂直对齐这个div

转载 作者:太空宇宙 更新时间:2023-11-04 15:38:33 25 4
gpt4 key购买 nike

This是我的实际代码:

<div class="main_right_content">
<div class="main_right_content_text">
my text is here and could be as long as possible. for example I write this code some times : my text is here and could be as long as possible. for example I write this code some times : my text is here and could be as long as possible. for example I write this code some times
</div>

<a class="main_right_content_link" href="#">Go</a>
</div>

我想,当我最小化窗口时,将链接“go”放在垂直对齐的中间。事实上,它始终位于顶部。

我如何使用 css(2) 做到这一点?

最佳答案

您可以使用 position: relative在容器上 div结合position: absolute; right: 0; top: 50%; margin-top: -<height/2>px在链接上。

参见: http://jsfiddle.net/mGJtu/22/

关于html - 如何垂直对齐这个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6329282/

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