我有一个包含段落、列表和右浮动 div 的 div。
父 div 有一个 text-align:justify; 财产。
我给 p 一个 20px 的(全方位)边距,但出于某种奇怪的原因,该段右侧的边距被忽略了。我在 ul 上尝试过,同样的事情发生了。
如果我不证明父 div 内的文本是合理的,则不会忽略边距。(但我确实希望它是合理的)。
浮动的 div 有一个边距:0;所以我想这不是利润率下降的问题。
浮动 div 是一个固定尺寸(像素)的 div,它是空的,除了背景图像。
我还尝试通过 margin-right:20px; 指定边距。它没有用......
我知道我可以通过在浮动 div 中添加左边距来解决它。但我想知道发生了什么。
这是我正在使用的代码(我只编辑了类名)。
CSS:
.parentDiv {
position: absolute;
width: 660px;
height: 350px;
z-index: -1;
background-color:#4F4F4F;
color:#FFFFFF;
text-align:justify;
overflow:hidden;
}
.foatedDiv {
float:right;
height:100%;
margin:0;
}
.parentDiv p {
margin:20px;
}
的HTML:
<div class="parentDiv">
<div class="floatedDiv" style="width:234px;background-image:url(images/jp01.jpg)"></div>
<strong><a href="someAnchor">Anchor</a></strong>
<p>Sope paragraph that I cannot understand why ignores its right margin and is driving me crazy.</p>
<strong>Some Topic</strong>
<ul>
<li>Some long item long enough to show there is no right margin.</li>
<li>Some long item long enough to show there is no right margin.</li>
<li>Some long item long enough to show there is no right margin.</li>
<li>Some long item long enough to show there is no right margin.</li>
</ul>
</div>
这就是我得到的: