控制文本与边框的距离,要使用css的内边距属性padding来实现。请看下方示例代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>angular demo</title>
</head>
<body>
<style type="text/css">
.box{width:150px;height:150px;border:1px solid #333;padding:10px;font-size:12px;}
</style>
<div class="box">
这里是测试的文字,修改padding值就可以改变文字距离边框的距离了。
</div>
</body>
</html>
示例中设置的padding值为10px;文字距离边框的距离即为10px。可通过修改值来改变距离。实现效果如下图:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/d4628535e5dde7115443b659a2efce1b9c166188?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)