当我想让我的文本从“block”标记右侧的左侧10px处开始时,会发生一些奇怪的事情。当我突然添加margin-left: 10px;
时,我的所有文本都消失了。任何想法是什么造成这种情况?我该如何解决这个问题?添加margin-left后,文字被推出屏幕:10px;
HTML:
<div id="container">
<div class="part">
<div class="part halfleft">
<p>
<img alt="" src="src.png" style="width: 469px; height: 371px; " /></p>
</div>
<div class="part halfright">
<h7> Title!</h7>
<p>
Sentence 1</p>
<p>
Sentence 2</p>
<p>
Sentence 3</p>
</div>
</div>
</div>
CSS:
#container {
margin-bottom: 60px;
}
/*….*/
#container h7 {
text-align: left;
width: 100%;
padding-bottom: 15px;
margin-bottom: 35px;
font-size: 30px;
}
#container .part {
width: 960px;
height: 475px;
background-color: #fff;
float: left;
text-align: left;
}
#container .part.halfleft {
width: 480px;
float: left;
font-size: 16px;
}
#container .part.halfright {
width: 480px;
float: left;
padding-top: 30px;
/*margin-left: 10px; or padding-left: 10px; pushes text off screen*/
font-size: 16px;
}
试着让你的宽度为470px,并重新添加边距,看看是否修复了它。我也建议在这种情况下使用填充。 – Michael 2013-03-27 13:04:49
感谢大家的快速回复!当然非常逻辑! – 2013-03-27 13:11:37