简体   繁体   English

div元素重叠而不是垂直对齐

[英]div elements overlapping instead of aligning vertically

I want a div element's top margin to match with the bottom of another, how can I do this? 我希望div元素的顶部边距与另一个元素的底部相匹配,我该怎么做?

Can I do it without using tables? 不用表格就可以吗?

<div style="text-align:left; position:absolute; left:12%;">
<input type="checkbox" name="acceptance" value="I have read and agree with the terms and conditions.">
<label style="text-align:left; color:yellowgreen ;font-size:27px ;font-family:cursive;font-style:italic;">I have read and agree with the terms and conditions</label>
</div>

<div style="text-align:center; width = 100%;">
<a href="i-hm-p.html";><img border="0"  src="images/imappyenter.png" width="100px"></a>
</div>

Please ignore my bad formatting, I'm editing someone else's code as well as learning CSS. 请忽略我的格式错误,我正在编辑其他人的代码以及学习CSS。

What I want to do is I want to place a checkbox at 12% of total width in a line, and a short explanation for it immediately after. 我想做的是我要在一行中的总宽度的12%处放置一个复选框,并在其后立即进行简短说明。 I've placed both in one div element. 我将两者都放在一个div元素中。

In another div element, I've placed a link wrapped in an image, which I want to align centrally while not being in the same line as the checkbox and its visible explanation. 在另一个div元素中,我放置了一个包装在图像中的链接,我希望该链接居中对齐,而不是与复选框及其可见说明在同一行。

How can I do this? 我怎样才能做到这一点?

只需将position:absolute更改为position:relative

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM