答案 0 :(得分:0)
如果您知道高度和宽度,则可以尝试以下操作:http://jsfiddle.net/9yvd68az/
HTML:
<div class="img-container">
<img src="https://i.imgur.com/uj0yKZZ.png"/>
</div>
CSS:
.img-container{
display: inline-block;
border: 2px solid blue;
height: 220px;
width: 220px;
}
.img-container img{
margin-left: 5px;
margin-top: 5px;
}
答案 1 :(得分:0)
使用伪代码可以达到预期的效果。
.dephased {
padding: 10px;
position: relative;
display: inline-block;
}
.dephased:before {
content: "";
position: absolute;
border: 3px solid blue;
top: -5px;
left: -5px;
width: 90%;
height: 90%;
z-index: -1;
}
<div class="dephased"><img src="https://via.placeholder.com/200x300"></div>