0
我有一段文字。我想在左侧留出20%的余量,并在右侧留出30%的余量。我如何使用CSS实现这一目标?用左右边距对齐文本块
下面是我的代码:
.style4 {
float: left;
margin-left: 20%;
background-color: #e5e0dd;
width: 68.1%;
margin-right: 30%;
border-left:30%;
text-align: center;
font-family: Calibri;
font-size: small;
}
<div class="style4">
This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.This is a test.
</div>
您已经拥有'margin-left:20%'和'margin-right:30%'。什么不适合你的? – 2012-07-05 21:58:32
此文本位于块的顶部,该边距为20%,30%为该块。该区块剩余20%剩余和30%右边距。该块上的文本不显示该边距。 – 2012-07-05 22:00:18