gpt4 book ai didi

php - 将一个元素与另一个元素居中?

转载 作者:行者123 更新时间:2023-11-28 14:19:51 25 4
gpt4 key购买 nike

假设我有这样的代码:

<div id="thisone">Content</div>
<div id="thatone">More Content</div>

假设两个元素都有背景颜色,所以你可以看到它们的大小,那么有没有办法根据id为#thatone的元素对齐id为#thisone的元素?谢谢!

(编辑:其中一个元素有 position:fixed,而另一个是 position:static)

最佳答案

您能否更好地解释一下您要实现的目标?当您添加了“center”标签时,也许您想要这样的东西?

<style>
#thisone {
background-color: red; width: 200px; height: 80px;
margin-left: auto; margin-right: auto;
}
#thatone {
background-color: blue; width: 200px; height: 80px;
margin-left: auto; margin-right: auto;
}
</style>
<div id="thisone">Content</div>
<div id="thatone">More Content</div>

(这应该使两个 div 在其父级中居中)

关于php - 将一个元素与另一个元素居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8642126/

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