准备项目
项目开发工具
Visual Studio Code 1.44.2
版本: 1.44.2
提交: ff915844119ce9485abfe8aa9076ec76b5300ddd
日期: 2020-04-16T16:36:23.138Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19044
项目结构
index.html代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>图片flex布局</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
display: flex;
height: 200px;
border: 1px solid #000;
justify-content: space-between;
}
.box div {
width: 100px;
height: 100px;
}
img {
width: 100%;
}
</style>
</head>
<body>
<div class="box">
<div><img src="./images/1.jpg" alt=""></div>
<div><img src="./images/1.jpg" alt=""></div>
<div><img src="./images/1.jpg" alt=""></div>
</div>
</body>
</html>
总结
此代码可以实现图片的水平居中分散对齐并且图片两边没有间距的展示效果,能够让图片展示更加美观。