English 中文(简体)
我怎么能防止浮小块继承其微薄的微粒?
原标题:How can I prevent a floated div from inheriting his sibling s margin-top?

我有一条像这一样本一样的《html法典》:

<html>
  <body>
    <div id="A" style="float:right; Background-color: Red;">Alpha</div>
    <div id="B" style="margin-top: 20px; Background-color: Green;">Bravo</div>
  </body>
</html>

我所要达到的是,上角的半衰期为零,而B div从上页的左上20个餐厅上调。 如下文所示,这确实是我想要的E8, 但它在 Chrome和 Firefox中做了大量的工作。

“entergraph

由于经常发生这种情况,我相信 Chrome和FF会这样做是正确的,而且IE8不符合标准。 因此,我的问题是,我如何能够在所有浏览器中取得预期的结果(在SS中,IE做了些什么)?

EDIT1&2:我编辑了屏幕,以显示我确实希望布拉沃迪夫留在阿尔法迪夫的左边但20px 下,如果我简单地在布拉沃增加一个明确的权利,则不喜欢。

增 编

最佳回答

EDIT
Answer to the new question:

<div id="A" style="float:right; background-color: Red; margin-top: -5px;">Alpha</div>
<div id="B" style="margin-top: 20px; background-color: Green;">Bravo</div>

ORIGINAL
(The question author originally asked this and later changed the question...)

http://www.un.org/Depts/DGACM/index_french.htm 选用<代码>clear: both;。 而将A类包装成像:

<div id="wrapper" style="overflow: hidden;">
    <div id="A" style="float:right; background-color: Red;">Alpha</div>
</div>
<div id="B" style="margin-top: 50px; background-color: Green; clear: right;">Bravo</div>
问题回答

为此:

<html>
  <body>
    <div id="A" style="float:right; Background-color: Red;">Alpha</div>
    <div id="B" style="float:right; margin-top: 50px; Background-color: Green; clear:right; width:100%;">Bravo</div>
  </body>
</html>

添加:

<>条码>float:right; clear:right;和width:100%;#B

See it in action -

添加一个<条码>明细表,以至圆形,使用最适合有关地点的财产。

参看。 因此,你没有任何一方。

<html>
  <body>
    <div id="A" style="float:right; Background-color: Red; ">Alpha</div>
    <div id="B" style="margin-top: 50px; Background-color: Green; clear: both;">Bravo</div>
  </body>
</html>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...