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