【发布时间】:2019-07-03 01:40:17
【问题描述】:
我正在尝试在按钮内添加一个图像,并希望将其居中对齐,因为我已将背景位置作为中心,但它仍然正确对齐。任何人都可以向我建议我应该如何将它对齐在中心?
demo.html
<html lang="en">
<head>
<link rel="stylesheet" href="demo.css">
<title>Document</title>
</head>
<body>
<button class="closeIconRegion"> <span class="closeIconStyle"> </span></button>
</body>
</html>
demo.css
.closeIconRegion {
position: relative;
overflow: hidden;
width: 30px;
height: 30px;
background: Orange;
}
.closeIconStyle {
cursor: pointer;
display: block;
height: 25px !important;
width: 25px !important;
background-position: left;
background-image: url(/images/closebtn_white.png);
float: left;
}
输出::
【问题讨论】: