如何将我的图像在 div 容器外对齐一半?

How to align my image half way outside of div container?

是否可以将我的图像定位在 div 边缘的一半位置? (类似于示例代码中的右侧)。并且需要完成,只有 html 对齐功能?

body {
    background-color: #6B6B6B;
    margin: 50px;
    
    font-family: Arial;
    color: white;
    font-size: 14px;
}
<div align="left" style="height:50px;width:70px;background:rgba(0, 0, 0, .4);"><img src="http://wizzfree.com/pix/smiley2.png" width="32"></div><p></p>
<div style="height:50px;width:70px;background:rgba(0, 0, 0, .4);"><img src="http://wizzfree.com/pix/button6.png" width="90"></div>

<p>button outside to right abit<p>need to create similar effect on leftside</p>of simley icon above!

我怎样才能让它工作? 任何建议或想法都会对我很有帮助。谢谢 yummi

步骤:1

只需将 margin-left 添加到您的图片中

body {
    background-color: #6B6B6B;
    margin: 50px;
    
    font-family: Arial;
    color: white;
    font-size: 14px;
}
<div align="left" style="height:50px;width:70px;background:rgba(0, 0, 0, .4);"><img src="http://wizzfree.com/pix/smiley2.png" style="    margin-left: -38px;" width="38"></div><p></p>
<div style="height:50px;width:70px;background:rgba(0, 0, 0, .4);"><img src="http://wizzfree.com/pix/button6.png" width="90"></div>

<p>button outside to right abit<p>need to create similar effect on leftside</p>

步骤:2

你可以把那个 div 和图像放到一个母 div 中,然后在那个母 div 中你可以添加 display flex

body {
        background-color: #6B6B6B;
        margin: 50px;
        
        font-family: Arial;
        color: white;
        font-size: 14px;
    }
<div style="display: flex">
      <img src="http://wizzfree.com/pix/smiley2.png" style="    margin-left: -38px;" width="38">
      <div align="left" style="height:50px;width:70px;background:rgba(0, 0, 0, .4);"></div>
</div>