我有一段文字。我想在左侧放置 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>
最佳答案
我认为您可能希望在此处进行填充而不是边距。
padding-left: 20%; padding-right: 30%;
关于css - 将文本 block 与左右边距对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11353106/