
CSS 框模型 (Box Model) 规定了元素框处理元素内容、内边距、边框 和 外边距 的方式。两个图片之间的距离可以用外边距(margin)来实现:
margin: top right bottom left;
margin 可以单独改变元素的上,下,左,右边距,也可以一次改变所有的属性。
示例:设置图片间距为20px
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Page Title</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<style type="text/css">
img{
margin: 20px;
}
</style>
</head>
<body>
<img src="img/3.webp" alt="example">
<img src="img/3.webp" alt="example">
<img src="img/3.webp" alt="example">
<img src="img/3.webp" alt="example">
<img src="img/3.webp" alt="example">
<img src="img/3.webp" alt="example">
</body>
</html>效果如下:
推荐:css文档
以上就是css怎样设置图片之间的间隔?的详细内容,更多请关注易知道|edz.cc其它相关文章!














