图片在div里面如何居中
<style type="text/css">
body {
background-color: #ececec;
}
.d1 {
text-align: center;
position: relative;
height: 200px;
}
.d2 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="d1">
<span class="d2">
<img width="100px" height="100px" src="../image/api_1.png" alt="">
<p>ssss</p>
</span>
</div>