问题是我试图将siginimage的左边框设置为40px
,但是由于signinimage的高度是25px
,边框高度也被设置为25px
。
.top-header{
float: left;
border-left: 2px solid #CCCCCC;
height: 30px;
margin-top: 0px;
}
#signinimage{
padding-top: 6px;
padding-left: 10px;``
height: 25px;
width: 25px;
}
<img src="images/signinimage.png" class="top-header" id="signinimage">
发布于 2018-06-07 03:53:23
要获得比图像更高的边框,可以将图像包装在容器中,然后将该边框应用于该容器。
.top-header{
float: left;
border-left: 2px solid #CCCCCC;
height: 40px;
margin-top: 0px;
/* Center the image vertically */
display: flex;
align-items: center;
}
#signinimage{
height: 25px;
width: 25px;
padding-left: 10px;
}
<div class="top-header">
<img src="http://placekitten.com/25/25" id="signinimage">
</div>
https://stackoverflow.com/questions/50728111
复制相似问题